Basic JavaScript: Testing Objects for Properties Code

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

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

// Test your code by modifying these values

guys why my code is not working. I know it is a different approach but it all seems to be working.


this is the problem i believe.

There is no ‘checkProp’ property in myObj
The available properties that you can access with dot notation are gift, pet and bed.
Try using bracket notation instead of dot notation.

1 Like

Thanks :grinning: I have searched over the MDN and I found the solution :fu: