Trying to solve using Nested For Loops

I’ve solved this challenge already but I’d like to try using nested for loops. I cannot figure out why my code is not working. Console is saying “undefined”

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

obj = [];
let newObj = ['Alan', 'Jeff', 'Sarah', 'Ryan'];
for ( let j = 0; j < obj.length; j++ ) {
for ( let i = 0; i < newObj.length; i++ ) {
if ( obj[j] == newObj[i]) {
       return true;
     } return false;
     }
     }

// Only change code above this line
}


console.log(isEveryoneHere(users));
  **Your browser information:**

User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 11_2_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/89.0.4389.114 Safari/537.36.

Challenge: Check if an Object has a Property

Link to the challenge:

so j < obj.length is always false
why are you overwriting the function parameter?


I’ve edited your post for readability. When you enter a code block into a forum post, please precede it with a separate line of three backticks and follow it with a separate line of three backticks to make it easier to read.

You can also use the “preformatted text” tool in the editor (</>) to add backticks around text.

See this post to find the backtick on your keyboard.
Note: Backticks (`) are not single quotes (').

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.