you are returning **count variable ** inside for in ,wich means that you are stopping the loop
because the function when it returns something its job stops .
so here in your code you are looping through the first key in the obj (the given object) ,and however the result is , after the if statment it will return 0 or 1 and the function stops
and also change users to another name to not mislead yourself with the name of the object wiich is also users use whaterver name you want instead
one of the benefits of using bracket notation is we can use variable inside the brakcet notation to access an objetc property
so here online is a variable
so you can access online property like this
ob[online].online because online is a variable it should be inside bracket notation
let count = 0;
for (let a in obj) {
if (obj[a].online == true) { // so I changed online var by a var beause we have already online property
count++;
}
}
return count;