Tell us what’s happening:
Describe your issue in detail here.
I found this code in the hint section of this lesson , It works but i dont understand why it works.
function checkObj(obj, checkProp) {
// Only change code below this line
if (obj.hasOwnProperty(checkProp)) {
return obj[checkProp];
} else {
return "Not Found";
}
**i just do not understand how it correlates to the subject, how to get to this code in relation to the questions asked.**
* `checkObj({gift: "pony", pet: "kitten", bed: "sleigh"}, "gift")` should return the string `pony`.
* Passed:`checkObj({gift: "pony", pet: "kitten", bed: "sleigh"}, "pet")` should return the string `kitten`.
* Passed:`checkObj({gift: "pony", pet: "kitten", bed: "sleigh"}, "house")` should return the string `Not Found`.
* Passed:`checkObj({city: "Seattle"}, "city")` should return the string `Seattle`.
* Passed:`checkObj({city: "Seattle"}, "district")` should return the string `Not Found`.
* Passed:`checkObj({pet: "kitten", bed: "sleigh"}, "gift")` should return the string `Not Found`.
The object list is nowhere to be found so on what is this code checking its validdity?
User Agent is: <code>Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/103.0.5060.134 Safari/537.36 Edg/103.0.1264.77</code>
**Challenge:** Basic JavaScript - Testing Objects for Properties
**Link to the challenge:**
https://www.freecodecamp.org/learn/javascript-algorithms-and-data-structures/basic-javascript/testing-objects-for-properties