Tell us what’s happening:
Describe your issue in detail here.
This code must also be right by the logic of the lesson. Please suggest why the logic is wrong.
Your code so far
const users = {
Alan: {
online: false
},
Jeff: {
online: true
},
Sarah: {
online: false
}
}
function countOnline(allUsers) {
// Only change code below this line
let count = 0;
for (const user in allUsers) {
for (const online in user) {
if (user[online] == true) {
count++;
}
}
}
return count;
// Only change code above this line
}
console.log(countOnline(users));
Your browser information:
User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/122.0.0.0 Safari/537.36
Challenge Information:
Basic Data Structures - Iterate Through the Keys of an Object with a for…in Statement