(Help!)Iterate Through the Keys of an Object with a for...in Statement

Whats up!
I feel I have formatted the loop and the if statement as per the rules and the hints I saw. The issue I am having is returning the result. Either my mind blanked how to return something with values or something in this code is wrong or missing. I don’t think the return statement is right because it doesn’t reference the origin with notation, and even if it did it would probably just return the users in userObj without the results I wanted to return. Some help would be appreciated thanks!


function countOnline(usersObj) {
// Only change code below this line
for (let user in usersObj) {
if (usersObj[user].online===true) {
  
}
}
// Only change code above this line
}



Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/84.0.4147.105 Safari/537.36.

Challenge: Iterate Through the Keys of an Object with a for…in Statement

Link to the challenge:

1 Like

Try running it without [user]. I think you don’t nees to put it in there since it’s for of loop.

1 Like

You just need to return the number of users that is online.

1 Like

I tried that but I think you need it to reference where you are accessing.

I tried return user; and return usersObj[user].online; not working

Remember, “number” of users.

1 Like