- Testing Objects for Properties

I am unable to render this code. I presume it’s because gift has been defined as “pony”, so trying to make it render for “Not Found” too is a bit tricky. Please help.


function checkObj(obj, checkProp) {
// Only change code below this line
var checkObj = {
  gift: "pony",
  pet: "kitten",
  bed: "sleigh",
  city: "Seattle",
};
if(checkProp == "gift") {
return "pony";
} else if(checkProp == "pet") {
return "kitten";
} else if(checkProp == "house") {
return "Not Found";
} else if(checkProp == "city") {
  return "Seattle";
} else if(checkProp == "district") {
  return "Not Found";
} else if (checkProp == "gift") {
  return "Not Found"
}
// Only change code above this line
}

Challenge: Testing Objects for Properties

Link to the challenge:

You should not hard-code this function with the answers. That misses the point of the challenge. Do you remember this challenge:

1 Like