Hi, I’m trying to solve this one, but I don’t know where to go with it. I don’t like how the entire code isn’t in the code block and how I’m referring to properties online, user when it’s elsewhere. Not sure why we wouldn’t just have it in the code. Even the example is missing the function.
- I noticed the hint uses obj not usersObj, why is that?
- Read somewhere I should console.log to find the problem, I still don’t know how to use console.log effectively to debug (tried replacing count++ with console.log(user); but nothin happened)
Thanks
Your code so far
function countOnline(usersObj) {
// Only change code below this line
for (let user in usersObj) {
if (usersObj[user].online === true) {
count++;
}
}
// Only change code above this line
}
Your browser information:
User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/88.0.4324.96 Safari/537.36
.
Challenge: Iterate Through the Keys of an Object with a for…in Statement
Link to the challenge: