Parentheses or brackets

Parentheses or brackets
0.0 0

#1

why is it “return myobj[checkprop]”. why cant it use parentheses instead? like checkprop does on the above line?

Your code so far

// Setup
var myObj = {
  gift: "pony",
  pet: "kitten",
  bed: "sleigh"
};

function checkObj(checkProp) {
  // Your Code Here
if (myObj.hasOwnProperty(checkProp)) {
  return myObj[checkProp];
} else {
  return "Not Found";
}
  
}

// Test your code by modifying these values
checkObj("pet");

#2

Brackets and parentheses have completely different meanings. checkProp is the argument in a function call. checkObj and hasOwnProperty are both functions. myObj is an object, not a function.