Testing Objects

Please help, this is my code and the answer comes back as it should be but I guess i’m doing something wrong because I still get an X on "it should return “Not Found!”.

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

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

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

Hello there!

I think the logic is fine—if it’s only “house” that’s not working, it’s most likely because the string that should be returned is "Not Found" but not "Not Found!".

I hope that helps. :slight_smile:

1 Like

Thank you very much, I guess always overthinking and not looking at the little stuff.:grin:

I cleaned up your code.
You need to use triple backticks to post code to the forum.
See this post for details.