Why does this work only without the brackets?

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

this function is not returning anything, you need a function that returns something

this function uses arrow function’s implicit return

3 Likes

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.