Strange logs in Basic Data Structures: Iterate Through the Keys of an Object with a Statement

Evening all,

I’m having a little trouble with

Here is my code:

let users = {
  Alan: {
    age: 27,
    online: false
  Jeff: {
    age: 32,
    online: true
  Sarah: {
    age: 48,
    online: false
  Ryan: {
    age: 19,
    online: true

function countOnline(obj) {
  // change code below this line
  let counter = 0;
  let user = '';
  for (user in obj); {
      if(obj[user].online == true){  
      counter ++;
    return counter;
  // change code above this line


At the moment, I am only logging 1 for the countOnline function. I wanted to check my input with further logs on the user, but when I checked my console it returns “Ryan” and “Carl”, which isn’t even in the object.

My questions are:

  1. Why am I skipping over Jeff?
  2. Where did Carl come from?


Thanks in advance.

For some reason you have a semi-colon after the for loop closing ). This prevents the loop from iterating passed the first property.

As far as the Carl property showing up, that is something involving the tests behind the scenes. I believe there is a bug with the tests on this challenge which has not been fixed yet. Remove the semi-colon an and your solution will be correct.

1 Like

Very well spotted. Thank you very much, Randell.