Why does this work only without the brackets?
function isEveryoneHere(userObj) {
return ['Alan', 'Jeff', 'Sarah', 'Ryan'].every(name =>
userObj.hasOwnProperty(name)
);
}
If I put an opening and closing bracket like this it won’t work, it returns false:
(name => {
userObj.hasOwnProperty(name);
});
setup code
let users = {
Alan: {
age: 27,
online: true
},
Jeff: {
age: 32,
online: true
},
Sarah: {
age: 48,
online: true
},
Ryan: {
age: 19,
online: true
}
};
**Challenge:** Check if an Object has a Property
**Link to the challenge:**
https://www.freecodecamp.org/learn/javascript-algorithms-and-data-structures/basic-data-structures/check-if-an-object-has-a-property