question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[Bug] Basic Data Structures: Check if an Object has a Property

See original GitHub issue

Describe 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:closed
  • Created 5 years ago
  • Comments:8 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
RandellDawsoncommented, May 25, 2019

@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.

1reaction
RandellDawsoncommented, May 17, 2019

@razzlestorm It has been fix but not deployed to production.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found