Need help with this please

Tell us what’s happening:

Your code so far


function countOnline(usersObj) {
// change code below this line
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){
let count = 0;
for (let user in obj){
if(obj[user].online===true) ?
onlineUsers = onlineUsers + 1;
}
}
return onlineUsers;
}
// change code above this line
}
console.log(countOnline(users));

Your browser information:

User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_6) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/12.1.1 Safari/605.1.15.

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

Hello,

You have defined the function countOnline twice remove the second one.

you have initialized the count variable but use the onlineUsers variable to count the number of true use any one of them.

there is no need of this as the challenge automatically substitutes the object.

Happy coding