[ UPDATE ]
Change
for ( **const** property in usersObj)
on
for ( **let** property in usersObj)
And now work
When “Run the Tests” show one error
The function countOnline should use a
for in
statement to iterate through the object keys of the object passed to it.
What is wrong ? My code below
Your code so far
function countOnline(usersObj) {
// Only change code below this line
let value = 0;
for ( const property in usersObj){
value += (( usersObj[property].online === true)) ? 1 : 0;
}
return value;
// Only change code above this line
}
Your browser information:
User Agent is: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.113 Safari/537.36
.
Challenge: Iterate Through the Keys of an Object with a for…in Statement
Link to the challenge:
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