Tell us what’s happening:
I do not understand why dot notation must be combined with bracket notation here. The user is a property of usersObj, and online is a property of user, so why can’t we access the value using either usersObj.user.online or usersObj[user][online]? Why does it have to be a combination? This seems rather arbitrary to me, so I must be missing something important here.
**Your code so far**
function countOnline(usersObj) {
// Only change code below this line
let count = 0;
for (let user in usersObj) {
if(usersObj[user].online == true) {
console.log(usersObj[user].online);
count++;
}
}
return count;
// Only change code above this line
}
**Your browser information:**
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4430.85 Safari/537.36.
Challenge: Iterate Through the Keys of an Object with a for…in Statement