The syntax in JavaScript for accessing the property of an object is:
object.property or object["property"] or object[property]
I was trying out this lesson on freeCodeCamp:
var myObj = { gift: "pony", pet: "kitten", bed: "sleigh" };
function checkObj(checkProp) {
  if( myObj.hasOwnProperty(checkProp) )
    return myObj[checkProp];
  return "Not Found";
}
checkObj("gift");
... the console displays the expected prop with object[property] syntax and undefined otherwise. Why is this?
 
     
    