Hi,
Hi, I would like to know why do I get undefined when I use the dot to access to “myObj”; why do I need to use the square brackets instead of the dot. Thanks for the answer in advance
My Code:
// Setup
var myObj = {
gift: "pony",
pet: "kitten",
bed: "sleigh"
};
function checkObj(checkProp) {
// Only change code below this line
if (myObj.hasOwnProperty(checkProp)) {
return myObj.checkProp; //HERE IS THE QUESTION
} else {
return "Not Found";
}
// Only change code above this line
}