Check if property exists in object
How to solve it
A very simple solution to solve this exercise is to use the in operator. The in operator can be applied to any object. It checks if a property with a certain key exists in the object:
const obj = { x: 1 };
console.log('x' in obj);
// output: true
console.log('a' in obj);
// output: false
The value of the property does not matter in this case, even if it is undefined. As long the property itself exists in the object, the in operator return true: const obj = { x: undefined };
console.log('x' in obj);
// output: true