I don't know why it isn't working

Tell us what’s happening:

Your code so far

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

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

// Test your code by modifying these values

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.149 Safari/537.36.

Challenge: Testing Objects for Properties

Link to the challenge:

The challenge link you’ve provided is having a different function signature.
The checkObj function that tests run against is: function checkObj(obj, checkProp).

What you are doing inside of the function is right but the tests that are running against your code assume that your function is having two parameters. one for the object or(obj) and one for the checkProp to check if that prop is in the object.

yeah, thanks a lot. I didn’t notice that, it’s working now.

1 Like

If you put both myObj and checkObj in one single file, it works perfectly without issues. If you separate the two then the logic will break since it will be unable to find the variable myObj, there perfect design would be as suggested by shervinee.