JS Obj Test not passing test perimeters

Tell us what’s happening:
This is getting passed back missing almost each of the test perimeters even though its returning the right amount.

I checked the modal solution and it’s pretty much identical minus variable names inside the function.

What’s going on?

  **Your code so far**

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

return userOnline;

// 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/89.0.4389.90 Safari/537.36.

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

Link to the challenge:

your userOnline variable is not declared. It should be let userOnline=0

userOnline = 0;

This is a global variable you’ve created, I’m on a phone so can’t really check how it fails in practice, this but it’s going to cause the tests to fail one way or another.

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