Check if an Object has a Property code

The code below doesn’t work, but I can’t see why. The code in the hint/solution is a bit odd as it doesn’t actually use the function parameter (obj), also, it gives multiple parameters to hasOwnProperty, but this only takes one parameter so will only test the first parameter as far as I can see.

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

function isEveryoneHere(obj) {
  // change code below this line
  for (let i = 0; i < obj.length; i++) {
    if (users.hasOwnProperty(obj[i]) === false) {
      return false;
  return true;
  // change code above this line


Link to the challenge:

The task is to check if users object contains all four names, Alan , Jeff , Sarah , and Ryan , as keys.
Your loop is not checking for any of these keys and I don’t believe you can loop through an object using a for loop used for an array.

The reason a for loop won’t work is that object properties are not indexed. What that means is that there is no obj[1] or anything like that. So you are not looping through the object to check the names. You need to check if the obj has a property for each name.

This means that you need to check if obj has 4 different properties. You could write 4 different obj.hasOwnProperty('Name') statements, or you can put them all in one ex.
obj.hasOwnProperty('Name1', 'Name2', 'Name3', 'Name4') is the same as