Testing Objects for Properties.I am stuck here from several hours

Tell us what’s happening:
Hi campers! I don’t know what’s wrong with my code.I have tried to solve this problem by consulting several different posts but it still does not work.I am stuck here from several hours.Please guide me :confused:

  **Your code so far**

function checkObj(obj, checkProp) {
// Only change code below this line
var myList = {
"gift":"pony",
"pet": "kitten",
"bed": "sleigh",
"city": "Seattle"
};

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

// Only change code above this line



console.log(checkObj({gift: "pony", pet: "kitten", bed: "sleigh"}, "gift"));
console.log(checkObj({pet: "kitten", bed: "sleigh"}, "gift"));
console.log(checkObj({gift: "pony", pet: "kitten", bed: "sleigh"}, "pet"));
console.log(checkObj({city: "Seattle"}, "city"));
console.log(checkObj({gift: "pony", pet: "kitten", bed: "sleigh"}, "house"));
console.log(checkObj({city: "Seattle"}, "district"))
  **Your browser information:**

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

Challenge: Testing Objects for Properties

Link to the challenge:

1 Like

Change the myList into obj it should work now and remove that myList var

1 Like

I have tried.It still not working @Excardical

Can you share your updated code with us?

You don’t need this part at all.

You don’t need to create your own object.

You just need the if else statement to pass the test using the correct parameter instead of myList.

I tried to fiqure out my mistake but could not found.Thank you so much @jwilkins.oboe :hugs:

1 Like