// Setup
var myObj = {
gift: “pony”,
pet: “kitten”,
bed: “sleigh”
};
function checkObj(checkProp) {
// Your Code Here
return (myObj[checkProp] ? myObj[checkProp] : “Not Found”);
}
// Test your code by modifying these values
checkObj(“gift”);
Like that I can pass to the next level, but if I try different (2 different ways) it doesn’t allow me…what’s the problem?
if I try to write :
return (myObj.hasOwnProperty(“checkProp”) ? myObj[checkProp] : “Not Found”);
or
if(myObj.hasOwnProperty(“checkProp”)) {
return myObj[checkProp];
}
return “Not Found”;
}
it doesn’t want…
Could someone help me to understand what’s the problem. Why myObj.hasOwnProperty(“checkProp”) it show false all the time?
Why myObj[checkProp] is good and myObj.hasOwnProperty(“checkProp”) is not?
Thank you in advance