Testing Objects for Properties - stuck on last part of the challenge :(

Tell us what’s happening:
Describe your issue in detail here.

With this code I have passed all of the challenges except the last. I do not understand how to make the function return True for the “gift” property while simultaneously returning “Not Found” after passing “gift” through later. I have tried to make a second object that excludes the “gift” property but that just makes me pass the last challenge but fail the first. Any explanation of how this logic works would be so incredibly helpful - thank you in advance!!

  **Your code so far**

function checkObj(obj, checkProp) {
// Only change code below this line


obj = { "gift": "pony", "pet": "kitten", "bed": "sleigh", "city": "Seattle"}


if (obj.hasOwnProperty(checkProp)){
return obj[checkProp];
}
else {
return "Not Found";
}

// Only change code above this line
}

  **Your browser information:**

User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/96.0.4664.110 Safari/537.36

Challenge: Testing Objects for Properties

Link to the challenge:

Why did you redefine obj?

1 Like

I thought that I had to in order to assign the correct values to each property… however I just deleted that line and it worked. I still don’t quite understand how it automatically knows without me defining the object like that though

obj is a function argument. It is passed into the function when called.