hasOwnProperty()
method and the other uses the in
keyword. If we have an object users
with a property of Alan
, we could check for its presence in either of the following ways:
```js
users.hasOwnProperty('Alan');
'Alan' in users;
// both return true
```
users
, with some users in it and a function isEveryoneHere
, which we pass the users
object to as an argument. Finish writing this function so that it returns true
only if the users
object contains all four names, Alan
, Jeff
, Sarah
, and Ryan
, as keys, and false
otherwise.
users
object should only contain the keys Alan
, Jeff
, Sarah
, and Ryan
testString: assert("Alan" in users && "Jeff" in users && "Sarah" in users && "Ryan" in users && Object.keys(users).length === 4);
- text: The function isEveryoneHere
should return true
if Alan
, Jeff
, Sarah
, and Ryan
are properties on the users
object
testString: assert(isEveryoneHere(users) === true);
- text: The function isEveryoneHere
should return false
if Alan
is not a property on the users
object
testString: assert((function() { delete users.Alan; return isEveryoneHere(users) })() === false);
- text: The function isEveryoneHere
should return false
if Jeff
is not a property on the users
object
testString: assert((function() { delete users.Jeff; return isEveryoneHere(users) })() === false);
- text: The function isEveryoneHere
should return false
if Sarah
is not a property on the users
object
testString: assert((function() { delete users.Sarah; return isEveryoneHere(users) })() === false);
- text: The function isEveryoneHere
should return false
if Ryan
is not a property on the users
object
testString: assert((function() { delete users.Ryan; return isEveryoneHere(users) })() === false);
```