Basic Data Structures: Iterate Through the Keys of an Object 'with a for...in Statement

Tell us what’s happening:

i have written the required code absolutely right but there is no built in consol.log to print the required result so this part is not appearing as solved.

Your code so far


function countOnline(usersObj) {
// Only change code below this line
let a = 0;
for (let user in obj) {
  if (obj[user].online === true) {
    a++;
  }
}
return a;

// 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/83.0.4103.61 Safari/537.36.

Challenge: Iterate Through the Keys of an Object with a for…in Statement

Link to the challenge:

Double check the name of the function argument compared to the variable name you are using in your for loop. You have a typo.

no, in this case the tests check what your function returns

you can totally use console.log statements yourself to check what your code is doing (absolutely suggested, debugging is really important to do)