Tell us what’s happening:
Describe your issue in detail here.
Your code so far
I don’t know what is wrong here, can someone help me?
const users = {
Alan: {
online: true
},
Jeff: {
online: true
},
Sarah: {
online: false
}
}
function countOnline(allUsers) {
// Only change code below this line
let num = 0;
for (let checkOnline in allUsers) {
if (allUsers[checkOnline].online === true) {
return num+=1;
}
}
return num;
// Only change code above this line
}
console.log(countOnline(users));
Your browser information:
User Agent is: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:109.0) Gecko/20100101 Firefox/113.0
Challenge: Basic Data Structures - Iterate Through the Keys of an Object with a for…in Statement
Link to the challenge: