Is this problem written wrong?

Tell us what’s happening:
This problem has to be written wrong. There is clear instructions that says
//Change code below this line
&&
//Change code above this

but in order for the answer to be accepted it needs all of the
let users = {
Alan: {
age: 27,
online: false
},
Jeff: {
age: 32,
online: true
},
Sarah: {
age: 48,
online: false
},
Ryan: {
age: 19,
online: true
}
};

above the function. Which is out of bounds for the problem.

Your code so far


let users = {
Alan: {
  age: 27,
  online: false
},
Jeff: {
  age: 32,
  online: true
},
Sarah: {
  age: 48,
  online: false
},
Ryan: {
  age: 19,
  online: true
}
};
function countOnline(obj) {
// 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/81.0.4044.138 Safari/537.36.

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

Link to the challenge:

it needs the users object only because you have added this and otherwise users is undefined

if you delete the function call, you can delete also the object declaration

1 Like

You do not need to change the starting code. The function will work no matter what the users object is. The ‘users’ object is only used in your own debugging and testing, not in the FCC test suite.

1 Like

That was it. The tool for debugging became the thing needing debugging. :rofl: