Currently on this lesson: https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/basic-data-structures/check-if-an-object-has-a-property
The hints section for this challenge says that we can look for the presence of multiple properties in an object by passing them all as multiple arguments inside the hasOwnProperty(). This is contrary to what I found in another source (https://stackoverflow.com/questions/48653543/hasownproperty-with-more-than-one-property), which says that hasOwnProperty looks for only the first argument.
I am not sure which one of them is correct, but I experimented by using an extra property as a parameter (my name “Pratik”, along with the ones the problem asked me to, i.e. Alan
, Jeff
, Sarah
, and Ryan
). Placing the extra parameter inside hasOwnProperty (the new parameter was not present in the given object, so the result should be false) always resulted in true, except when the new (nonexistent property) parameter was passed as the FIRST argument.
This supports the theory that hasOwnProperty() takes (or properly examines) only one argument, and if I am indeed correct, then I think the hints section is misleading and needs to be fixed.
Opinions? I am a beginner, so I would be happy to be corrected.
Thanks.