Tell us what’s happening:
I passed the challenge. However, the challenge states: " Finish writing this function so that it returns true
only if the users
object contains all four names, Alan
, Jeff
, Sarah
, and Ryan
, as keys, and false
otherwise." So if I change even one of the properties inside of the object being used here (I changed Ryan to Mark), shouldn’t the function I typed return false? I can only think that this is an error/typo in the challenge parameters. Which is fine, but either way I want to know how (if possible) to write a function that strictly needs all the properties I pass in to the hasOwnProperty() method.
Your code so far
let users = {
Alan: {
age: 27,
online: true
},
Jeff: {
age: 32,
online: true
},
Sarah: {
age: 48,
online: true
},
Mark: {
age: 19,
online: true
}
};
function isEveryoneHere(obj) {
// change code below this line
if (obj.hasOwnProperty(‘Alan’, ‘Jeff’, ‘Sarah’, ‘Ryan’)) {
return true
}
return false;
// change code above this line
}
console.log(isEveryoneHere(users)); ``// Still returns true!``
Your browser information:
User Agent is: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:67.0) Gecko/20100101 Firefox/67.0
.
Link to the challenge:
https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/basic-data-structures/check-if-an-object-has-a-property