Code is wrong, still passes, how? --- Check if an Object has a Property

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

while(users.hasOwnProperty(“Alan”)){
return true;
}
return false;

while checks whether some condition is true. What you’ve got is essentially the same as using if.

But I checked for Alan only and not the other users, how is this test passing then?

Ah, I see what you’re saying. Seems like the test could use some tweaking. Put up an issue and be a contributor!

1 Like