I’m facing an issue in the section Javascript Algorithms and Data Structures, more specifically the lesson Basic Data Structures: Iterate Through the Keys of an Object with a for…in Statement, here you have the link: 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.
I am running the code which I will attach here, but it doesn’t seem to recognize it as a solution, even though that seems to really be the solution, because the console is showing the right output even when I change the values of true and false in the object.
I may be wrong. That may not be the solution, but as far as I can see, it seems to be a bug.
I’ll be waiting for a response from your side, and if that’s a bug, I’ll be waiting for a fix as well. Please let me know!
Just in case the image doesn’t load up, I’m putting the code here as well:
const users = {
Alan: {
online: false
},
Jeff: {
online: true
},
Sarah: {
online: false
}
}
function countOnline(allUsers) {
// Only change code below this line
let count = 0;
for(let user in allUsers) {
if(users[user].online === true) {
count++;
}
}
return count;
// Only change code above this line
}
console.log(countOnline(users));