Tell us what’s happening: I was confused w/ the task for this section, so I submitted my wrong answer anyway to see what I was missing and got even more confused when references to “checkObj({gift: “pony”, pet: “kitten”, bed: “sleigh”}, “gift”)…should return the string pony.” The task instruction didn’t mentioned anything about pony, pet, kitten etc. I saw some of the solutions posted and need clarity on how the others know pets and pony were 2b added? I must’ve skipped a section or something.
**Your code so far**
function checkObj(obj, checkProp) {
// Only change code below this line
var checkObj = {
obj: "checkProp",
};
checkObj.hasOwnProperty("obj");
return "Change Me!";
// 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/89.0.4389.90 Safari/537.36.
You notice that I just made up two objects to check if those properties of dessert and food exist.
If you just have the if else statement in your function that you can test if these properties exist.
But with your current code you would have to back and add those key value pairs here
You want to create a function that can handle 100,200,500 test cases and pass all of them. And not by hardcoding every single value to get them all to pass. That would be exhausting.
That is why we have these two parameters here in the function
function checkObj(obj, checkProp)
So when we call the function it will test an object obj and property name checkProp