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.
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.
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