[Bug] Basic Data Structures: Check if an Object has a Property
See original GitHub issueDescribe your problem and how to reproduce it: Found from this PR https://github.com/freeCodeCamp/freeCodeCamp/pull/19367 The tests are only checking if all the properties exists and another check is done after deleting all the properties so code like:
function isEveryoneHere(obj) {
return users.hasOwnProperty('Alan', 'Jeff', 'Sarah', 'Ryan'); //shouldnt pass since .hasOwnProperty() doesnt take more than 1 parameter but would only check the first one.
}
and
function isEveryoneHere(obj) {
return obj.hasOwnProperty("Alan");
}
Passes the challenge whereas they shouldn’t.
This can be resolved by adding checks after deleting each property or randomly deleting one and then checking. Add a Link to the page with the problem: https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/basic-data-structures/check-if-an-object-has-a-property/
Tell us about your browser and operating system:
- Browser Name: Chrome
- Browser Version: 69
- Operating System: 10
Issue Analytics
- State:
- Created 5 years ago
- Comments:8 (5 by maintainers)
Top Results From Across the Web
FCC/17 - Check if an Object has a Property.md at master
Basic Data Structures : Check if an Object has a Property Finish writing this function so that it returns true only if the...
Read more >Basic Data Structures: Check if an Object has a Property has ...
In this challenge you need to check if “users” object contains ALL four names. Then return “true”. If any of names is missing...
Read more >Basic Data Structures: Check if an Object has a Property
In this lesson, we're supposed to use hasOwnProperty() to check if the users object contains Alan , Jeff , Sarah , and Ryan...
Read more >3 Ways to Check If an Object Has a Property in JavaScript
Every JavaScript object has a special method object.hasOwnProperty('myProp') that returns a boolean indicating whether object has a property ...
Read more >Objects - Definition & Usage - AutoHotkey
For all types of objects, the notation Object.LiteralKey can be used to access a property, array element or method, where LiteralKey is an...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@wudifeixue I completely agree with you, so I just created PR https://github.com/freeCodeCamp/freeCodeCamp/pull/36125 which adds two valid solutions to the article.
Keep in mind, even when the PR is merged, you will not see the Guide updated until the current
master
branch has been deployed to production.@razzlestorm It has been fix but not deployed to production.