Challenge itself
In this challenge you need to check if “users” object contains ALL four names. Then return “true”. If any of names is missing it should return “false”.
If you press “Get a hint” and look at the solutions, there are two options.
function isEveryoneHere(obj) {
// change code below this line
if(users.hasOwnProperty('Alan','Jeff','Sarah','Ryan')) {
return true;
}
return false;
// change code above this line
}
or
function isEveryoneHere(obj) {
return (users.hasOwnProperty('Alan','Jeff','Sarah','Ryan')) ? true : false;
}
While these solutions return “true” and pass the challenge, they are incorrect.
Take a look at this
Both solutions return true. Despite “users” having only one entry. These solutions return “false” ONLY if ‘Alan’ is missing. Other names doesn’t matter to this function.
Nope, it doesn’t. Try to remove any of the names, except the last one. And it will still return “true”. I’ve tried your way before, but after some debugging i found that none of these solutions work. I’ve completed this challenge and wrote a correct(but pretty simple and somewhat stupid) solution. But mods should change “solutions” in the guide.
function isEveryoneHere(obj) {
// change code below this line
return 'Alan' in obj && 'Jeff' in obj && 'Sarah' in obj && 'Ryan' in obj;
// change code above this line
}
Hi there, I was trying this too and also found that both solutions are incorrect… if you follow the solutions given in the hint, you can easily “pass” the challenge, but only the first name needs to be present for it to return true. As you can see in this screenshot:
Agree that the solution needs to be changed.
Edit: In another post a wiser user has shared some alternatives: