Check if Object has a thousands of Property

Check if Object has a thousands of Property
0

#1

hello guys!

my code below passed the test but i’m not still ok with it . what if the properties in the object were modified and i want the code to check if all the keys are in the object? for example, i have thousands of keys to check.

my passed code


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
if (obj.hasOwnProperty('Alan', 'Jeff', 'Sarah', 'Ryan')) {
  return true;
}
else {
  return false
}
  // change code above this line
}

console.log(isEveryoneHere(users));

Your browser information:

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

Link to the challenge:
https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/basic-data-structures/check-if-an-object-has-a-property


#2

Hey Zuriel,
Next challenge should answer your question.