Tell us what’s happening:
Describe your issue in detail here.
Hi all,
The challenge is asking me to finish writing the function so that it returns true
if the object passed to it contains all four names, Alan
, Jeff
, Sarah
and Ryan
and returns false
otherwise.
My code, while not the most efficient, does this. However, it won’t pass because I’m not meeting the criteria of
The users
object should not be accessed directly
I don’t understand what this means and how I’m accessing it directly. I’m not writing the name of the object directly into the function, it’s being passed in as a parameter or argument in the console.log.
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(userObj) {
// Only change code below this line
if ("Alan" in userObj == false) {
return false;
} else if ("Jeff" in userObj == false) {
return false
} else if ("Sarah" in userObj == false) {
return false
} else if ("Ryan" in userObj == false) {
return false
} else {
return true
}
// Only change code above this line
}
console.log(isEveryoneHere(users));
Your browser information:
User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/107.0.0.0 Safari/537.36
Challenge: Basic Data Structures - Check if an Object has a Property
Link to the challenge: