I have written a function to iterate through an object and is not working properly someone please help me and tell me where am I making a mistake in my function here is What I tried:
//Function Checking online User
let countOnline = (usersObj) => {
  let onlineUsers = 0;
  for (let user in usersObj) {
    if (user.online === true) {
      onlineUsers += 1;
    }
  }
  return onlineUsers;
}
//Sample Object
let obj1 = {
  Alan: {
    online: false
  },
  Jeff: {
    online: true
  },
  Sarah: {
    online: false
  }
}
console.log(countOnline(obj1));
 
    