I can't get past the for ...in challenge

Tell us what’s happening:

Your code so far


function countOnline(usersObj) {
// change code below this line
let result = 0;
for (let user in obj) {
  if (obj[user].online === true) {
    result++;
  }
}
return result;
// change code above this line
}
console.log(countOnline(users));

Your browser information:

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

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

Link to the challenge:
https://www.freecodecamp.org/learn/javascript-algorithms-and-data-structures/basic-data-structures/iterate-through-the-keys-of-an-object-with-a-for...in-statement

What is the error ? can you explain

where is obj defined in your code?

users is not defined.

Good question. :slight_smile:
I need to try again.
Thanks.

yes, also where have you defined users?
but that’s just a question of deleting the function call, the tests will have their own function calls
but the one not defined thing inside the function will make the function not work in its whole

thanks very much.
makes sense now.