Check if an Object has a Property [incorrect solution?]

Tell us what’s happening:
The hint/solution to this problem in freecodecamp has multiple arguments passed to the .hasOwnProperty(arg) method but when I check the MDN docs (https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/hasOwnProperty) it seems to suggest you can only have 1 argument passed to this - I mean you can pass multiple but it only actually tests the first one.

Amirite? or nah

Your code so far


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

return 
obj.hasOwnProperty('Alan') &&
obj.hasOwnProperty('Jeff') &&
obj.hasOwnProperty('Bob') &&
obj.hasOwnProperty('Ryan'); 

  // change code above this line
}

console.log(isEveryoneHere(users));

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/77.0.3865.90 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

1 Like

Who’s Bob and where’s Sarah?

Your mistake is that obj.hasOwnProperty('Bob') should be replaced with obj.hasOwnProperty('Sarah')

Edit: As for your question, FCC hint is wrong, only the first param is being checked, aka “Alan”