I'm trying to check if myObj has or not "x" properties. However, is not returning anything when myObj doesn't have the property I'm looking for. Here is the code:
var myObj = {
gift: "pony",
pet: "kitten",
bed: "sleigh"
};
function checkObj(checkProp) {
if(myObj.hasOwnProperty("gift")){
return myObj[checkProp];
} else if(myObj.hasOwnProperty("pet")){
return myObj[checkProp];
} else if(myObj.hasOwnProperty("bed")){
return myObj[checkprop];
} else {
return "Not Found";
}
}