Check Property javascript challenge

Tell us what’s happening:
I am having difficulty using “gift” to return Not Found. I have tried adding
“var obj = {pet: “kitten”, bed: “sleigh”};
checkObj(“gift”)”
after the last checkObj below, even attempted to add the function checkobj again.
I am at a loss.

  **Your code so far**

function checkObj(obj, 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";
}}

  checkObj("gift");
  checkObj("pet");
  checkObj("house");
  checkObj("city");
  checkObj("district");
  


// 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/92.0.4515.131 Safari/537.36

Challenge: Testing Objects for Properties

Link to the challenge:

Why are you redefining obj inside of the function?

obj is one of the arguments to the function and it should not be overwritten!

These are not valid function calls. Your function has two arguments but you’ve only supplied one argument.

You don’t create obj, it is being passed into your function as a parameter.

This is the function definition - the first parameter to be passed in is obj, the object you’re to test against. The second parameter is checkProp, a string denoting the name of the property you are to look for.

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.