JavaScript: Testing Objects for Properties can't figure out what I'm missing

Tell us what’s happening: when I run the test it checks off everything except
checkObj({gift: "pony", pet: "kitten", bed: "sleigh"}, "gift") should return "pony" .
but if i delete pet: “pony” it won’t check off

checkObj({pet: "kitten", bed: "sleigh"}, "gift") should return "Not Found" .

I can’t figure it out I think they contradict each other

Your code so far


//setup
var myObj = {
pet: "pony",
pet: "kitten",
city: "Seattle",
bed: "sleigh"
};
function checkObj(obj, checkProp) {
// Only change code below this line

if(myObj.hasOwnProperty(checkProp)) {
  return myObj[checkProp];
  } else {
    return "Not Found";
    }
    
}

// Only change code above this line


Your browser information:

User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_6) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/11.1.2 Safari/605.1.15.

Challenge: Testing Objects for Properties

Link to the challenge:

Hi @jonathan7135. Welcome to FCC.
You are supposed to use the parameter obj in the body of the function like:

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

what happens is that if i remove gift: “pony” it checks off the last test and un checks the first and if i add it back it checks of the first and un checks the last

What do you mean by if i remove gift:"pony"? There is nothing for you to remove. I suggest you click the Reset All Code button, as this lesson’s starting code has changed in the last few months, so you may not be starting with the most recent version of code.

function checkObj(obj, checkProp) {
// Only change code below this line
return “Change Me!”;
// Only change code above this line
}

this is the starting code for it

Yes, that is the correct starting code. Before, you posted some other code above the function declaration.

i got that from the youtube video

if i don’t add that none of the test check off

Yes, that video is out of date with the current challenge. The code you posted is on the right path, but your variable names are incorrect. Look at the warnings in the FCC console to see if you can figure out what they are. You should only be adding code inside the function. The objects used in the tests can be referenced in the function using the obj parameter. Fix your references and you will pass the challenge.

basically what i think happens the first test feeds gift and gets back pony and it checks it off but the last test feeds gift and it wants back not found so it doesn’t pass but if I delete gift: “pony” part of the code i get the opposite result first test fails last passes

i figured it out I had obj with capital Obj thank you.