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

I’m having an issue passing this challenge…I’m blatantly copying and pasting the posted answer but the site still says that I’m wrong. Is this an issue or am I wrong?

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
}
// change code above this line
console.log(countOnline(usersObj));

Your browser information:

User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/79.0.3945.130 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

you do not have anything named obj

2 Likes