Not sure why this isn't passing

Tell us what’s happening:

Pretty much what the title says. I have everything in line. Not sure what the problem can be.

Your code so far


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
}

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.122 Safari/537.36.

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

Link to the challenge:

Your return is inside of your loop. Your function stops the very first time you encounter a return. You want to put the return after the loop finishes.

1 Like

Oh my gosh, how did I not see that! Thanks for your help! I typically can tell when its something minuscule like that.

Thanks again!

1 Like

Sometimes you just need a second pair of eyes : )

1 Like