https://github.com/leta91/check-js-object-has-a-specific-property
How to check if a JavaScript object contains a specific property or not
https://github.com/leta91/check-js-object-has-a-specific-property
Last synced: about 1 month ago
JSON representation
How to check if a JavaScript object contains a specific property or not
- Host: GitHub
- URL: https://github.com/leta91/check-js-object-has-a-specific-property
- Owner: leta91
- License: mit
- Created: 2022-09-23T06:28:58.000Z (over 2 years ago)
- Default Branch: master
- Last Pushed: 2022-09-23T07:54:48.000Z (over 2 years ago)
- Last Synced: 2025-01-29T18:23:21.661Z (3 months ago)
- Language: JavaScript
- Size: 2.93 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
README
# Check if an Object has a Property (freeCodeCamp Challenge)
## "Basic Data Structures" ➡️ Chapter 5
## Part of the JavaScript Certification ➡️ Lesson 17### There are 2 ways to check for the existence of an object property:
1. `objectName.hasOwnProperty("propertyToCheck");`
2. `propertyToCheck in objectName;`that, applied to this challenge, become:
1. `peopleOnProjectObj.hasOwnProperty("Agnese"), peopleOnProjectObj.hasOwnProperty("Rian"), peopleOnProjectObj.hasOwnProperty("Michelle"), peopleOnProjectObj.hasOwnProperty("Aiden")`
2. `"Agnese" in peopleOnProjectObj && "Rian" in peopleOnProjectObj && "Michelle" in peopleOnProjectObj && "Aiden" in peopleOnProjectObj`
#### 🎯 Complete the Challenge:
Finish writing the function so that it returns *true* if the object passed to it contains all 4 names:
- `Agnese, Rian, Michelle` and `Aiden`
and returns *false* otherwise [^1][^1]: Double and single quotes are interchangeable in JavaScript