Individual keys in objects check not working

With my current code, I only get the first two tests to pass. The other four are failing. They are:

The function isEveryoneHere should return false if Alan is not a property on the users object
The function isEveryoneHere should return false if Jeff is not a property on the users object
The function isEveryoneHere should return false if Sarah is not a property on the users object
The function isEveryoneHere should return false if Ryan is not a property on the users object

So doesn’t my current code check for those and how do I make it so that it does? Thanks.

Your code so far


let users = {
Alan: {
  age: 27,
  online: true
},
Jeff: {
  age: 32,
  online: true
},
Sarah: {
  age: 48,
  online: true
},
Ryan: {
  age: 19,
  online: true
}
};

function isEveryoneHere(obj) {
// Only change code below this line
if (!("Sarah" in obj) && !("Jeff" in obj) && !("Ryan" in obj) && !("Alan" in obj)) {
  return false;
}
return true;
// Only change code above this line
}

console.log(isEveryoneHere(users));

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/83.0.4103.116 Safari/537.36 Edg/83.0.478.56.

Challenge: Check if an Object has a Property

Link to the challenge:

This condition is only true (meaning the function will return false) if none of those names are properties in obj. If any of those are present, you are returning true.

Yeah, that helped. Thanks.

if (!("Sarah" in obj && "Jeff" in obj && "Ryan" in obj && "Alan" in obj)) {
  return false;
}
return true;

FYI - because ("Sarah" in obj && "Jeff" in obj && "Ryan" in obj && "Alan" in obj) is a boolean, and you want to return a boolean, you don’t need an if/else.

You can just do this, if you want to.

return "Sarah" in obj && "Jeff" in obj && "Ryan" in obj && "Alan" in obj;