Iterate Through the Keys of an Object with a for…in Statement
Summary
- The for..in statement can be used to iterate through the keys within an object.
Final Code
function countOnline(usersObj) {
// Only change code below this line
let result = 0;
for (let user in usersObj) {
if (usersObj[user].online === true) {
result++;
}
}
return result;
// Only change code above this line
}