Whats wrong in my code?

Whats wrong in my code?


Tell us what’s happening:

Your code so far

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 count = 0;
  for (let obj in obj){
    if(obj['online'] == true){
        return count++;
        return count;
  // change code above this line


Your browser information:

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

Link to the challenge:


You are immediately returning count variable when you find or not find online to be true.

Only increment count variable inside the if statement.

Then before the function ends, return count.


@omkarkothavale88, I don’t know even where to start… let’s go line by line, can you please explain your logic here?

for (let obj in obj) {...


Just a heads up. Being rude to people is not likely to inspire them to want to get better.



@JordanMarsh It is not rude to ask campers seeking help to explain their logic. That is how we figure out what they are thinking to provide the best help possible.


I understand. It’s possible I misinterpreted what he was saying. The “I don’t even know where to start” was off putting.

My apologies.


I have learned to not try and read between lines which may or may not be there. :slight_smile:


What an amazing reply.

@omkarkothavale88, look into what a for…in loop actually does.