Help with testing objects for properties

I am a bit stuck in this exercise.

I looked at other’s solutions but I don’t understand how to make the computer to understand that when myObj.hasOwnProperty(checkprop) === city {
return "Seattle}

Could anyone explain step by step what are we trying to achieve please?

Here is the code so far:

function checkObj(myObj, checkProp) {

var myObj = {

gift: “pony”,

pet: “kitten”,

bed: “sleigh”,

}

if (myObj.hasOwnProperty(checkProp)) {

return(myObj[checkProp]);

} else {

return “Not Found”;

}

// Only change code above this line

}

checkObj(“gift”)

Your code so far


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

var myObj = { 
gift: "pony",
pet: "kitten",
bed: "sleigh", 

}

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


 // Only change code above this line
}

checkObj("gift")

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.163 Safari/537.36.

Challenge: Testing Objects for Properties

Link to the challenge:

You do not want to copy the code from the video. The video is for an older version of the challenge.

You instead want to use the knowledge from the video and the written description to accomplish the challenge.

You need to

  1. Change the parameter name back to obj instead of myObj
  2. Remove the declaration of myObj
  3. Edit the if statement to use obj
  4. Remove the added code below the Do not change comment

The Do not change comments need to be respected.

Creating your own myObj inside the function it makes the argument myObj pointless. This function is expected to take both an object and a property name and check that object for the property name.