Could you please help why I can't go through this question, though everything is good

Tell us what’s happening:
Describe your issue in detail here.

  **Your code so far**

function checkObj(checkProp) {
// Only change code below this line

 var obj = ({
gift: "pony",
pet: "kitten",
bed: "sleigh",
city: "Seattle",
});
if(obj.hasOwnProperty(checkProp)){
return obj[checkProp];
} else {
return "Not Found";
};
}
console.log(checkObj("pet"));
// Only change code above this line

  **Your browser information:**

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

Challenge: Testing Objects for Properties

Link to the challenge:

Do not change the signature of the function, do not remove any of the parameters (do not remove obj). This is the function you are provided in the starter code.

function checkObj(obj, checkProp) {
  // Only change code below this line
  return "Change Me!";
  // Only change code above this line
}
  1. The object you are testing for properties on is passed to the obj parameter, use that and do not create your own object.
1 Like

Thank you, but still it’s not going through.

We have to see your code. But I can tell you right now it will pass if you do what I said.

  1. Add back the obj parameter.

  2. Remove the object you created inside the function.

When I do that with your code we are left with this.

function checkObj(obj, checkProp) {
  // Only change code below this line
  if (obj.hasOwnProperty(checkProp)) {
    return obj[checkProp];
  } else {
    return "Not Found";
  };
}

Which passes all the tests.

1 Like

Thank you brother, it was helpful, appreciate it.