How do you make a new thing?
I’m sorry, but if you don’t know how to do that, you really need to go back to the basics
1 Like
I tried this
function countOnline(usersObj) {
// Only change code below this line
let count = 0;
for (let user in usersObj) {
if (usersObj[user].online === true) {
count += 1;
} else {
count += 0;
}
}
// Only change code above this line
}
console.log(countOnline({ Alan: { online: false }, Jeff: { online: true }, Sarah: { online: false } }));
there is not a return statement, the function returns undefined
1 Like
It works now, Thanks for the help.
Good to see you got it. Now you know, some parts of the code are informational. Other parts of the code you create yourself, such as variables. Because you can make the names of your variables, make sure to make good names that are descriptive. You can use the variable count
but how about naming it usersOnline
instead since it tells you exactly what you are counting.
1 Like
This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.