I’m having some trouble with this JS waypoint. As far as I can see my solution is correct. I’ve also checked it against the answers to make sure, and the example is literally exactly what I have. It still won’t validate. It gives me an error message:
checkObj(“house”) should return “Not Found”.
If I log checkObj("house")
to the console it gives me the right output.
I’ve tried a few minor syntax tweaks like using myObj.hasOwnProperty(checkProp) == true
and so on, but I can’t get this thing to go green. Any ideas?
Your code so far
// Setup
var myObj = {
gift: "pony",
pet: "kitten",
bed: "sleigh"
};
function checkObj(checkProp) {
// Your Code Here
if (myObj.hasOwnProperty(checkProp)) {
return myObj[checkProp];
}
else {
return "Not found";
}
}
// Test your code by modifying these values
checkObj("house");
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/73.0.3683.86 Safari/537.36
.