Help! I'm frustratedly stuck with this testing objects for properties" test

Hey!
Please I’m stuck in this “testing objects for properties test”, I’ve done everything humanly possible but can’t seem to get it right.

  **My code so far**

function checkObj(obj, checkProp) {
// Only change code below this line
if (checkObj.hasOwnProperty(checkProp)){
   return checkObj[checkProp];
}
else {
  return "Not Found";
}
// 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/91.0.4472.124 Safari/537.36

Challenge: Testing Objects for Properties

Link to the challenge:

Hi @heisemma !

The problem is here

and here

You are not using the obj parameter they gave you.
Instead you are using the function name of checkObj which is incorrect.

You need to use the parameter and then the test will pass.

1 Like

I’ve tried it, still not working
I changed the "return checkObj[checkProp] " to “return obj[checkProp]”.

Did you change the other one too?

Can you share your updated code?

2 Likes

Ooh I’ve seen the problem, thanks a lot.
I appreciate.

No I did not and that was the problem
Solved it, thanks a lot :handshake:.

var myObj = {

gift: “pony”,

pet: “kitten”,

bed: “sleigh”,

city:“Seattle”

};

function checkObj(obj,checkProp) {

if(obj.hasOwnProperty(checkProp))

return myObj[checkProp];

return “Not Found”;

}

// Test your code by modifying these values

checkObj(“gift”);