Confusing test pattern

Tell us what’s happening:
The test s include testing for “gift”. It expects two different answers; “pony” and “Not Found”. I can’t seem to figure out how to pass these tests, simultaneously. Please help!!!

   **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];
 }

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/90.0.4430.93 Safari/537.36.

Challenge: Testing Objects for Properties

Link to the challenge:

Hi @justobioma !

Welcome to the forum!

This challenge confuses a lot of people.

You do not need to create your own object.
You can delete this

The reason for deleting that is because you want to write a function that works with any object.

Not just the test cases that FCC provided for you.
That is why you shouldn’t hardcode an object and test it only against that.

the function is being tested with different objects, and instead of using the different objects passed in you are using always the same one. Why are you overwriting the function parameter?

1 Like

Thank you very much. This works now!

Hi @jwikins.oboe
Yes you are right. This works now. Now I know better!

1 Like

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