Tell us what’s happening:
I just want to report that the first test in this challenge fails if a variable’s name contains the word “users”, even if the variable doesn’t contain the users object.
The following code fails with "The users object should not be accessed directly"
function isEveryoneHere(userObj) {
// Only change code below this line
let usersList = ["Alan", "Jeff", "Sarah", "Ryan"];
for (let i = 0; i < usersList.length; i++) {
if (userObj.hasOwnProperty(usersList[i]) == false) {
return false;
}
}
return true;
// Only change code above this line
}
console.log(isEveryoneHere(users));
However, if you remove the word “users” from the variable name, then the test passes
function isEveryoneHere(userObj) {
// Only change code below this line
let List = ["Alan", "Jeff", "Sarah", "Ryan"];
for (let i = 0; i < List.length; i++) {
if (userObj.hasOwnProperty(List[i]) == false) {
return false;
}
}
return true;
// Only change code above this line
}
console.log(isEveryoneHere(users));
Challenge: Check if an Object has a Property
Link to the challenge: