Tell us what’s happening:
Need help please, i am struggling to solve this problem. What was the right answer.
This is my code let result = 0; for (let user in users) { if (users[user].online) { result++; } } return result;
Your code so far
function countOnline(usersObj) {
// Only change code below this line
let result = 0;
for (let user in users) {
if (users[user].online) {
result++;
}
}
return result;
// Only change code above this line
}
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:74.0) Gecko/20100101 Firefox/74.0
.
Challenge: Iterate Through the Keys of an Object with a for…in Statement
Link to the challenge: