Tell us what’s happening:
I can’t figure out why data isn’t printed when I test on REPL.
Your code so far
function countOnline(usersObj) {
// Only change code below this line
let n = 0;
for (let user in usersObj){
if (user.online === true){
return n++;
}
}
// Only change code above this line
}
Your browser information:
User Agent is: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/85.0.4183.121 Safari/537.36.
Challenge: Iterate Through the Keys of an Object with a for…in Statement
Can I know where I wrong? I’m so confused, I think that was the correct answer. Already compared with documentation didn’t wrong at parameter or something.
function countOnline(usersObj) {
// Only change code below this line
let n = 0;
console.log({n})
for (let user in usersObj){
console.log({user, 'user.online': user.online, 'user.online === true': user.online === true})
if (user.online === true){
console.log(user + ' is online')
return n++;
}
}
// Only change code above this line
}