Tell us what’s happening:
Hello,
I’ve spent about 4 hours trying to figure out what’s wrong with my code: for some reason it does not return “Not found” when testing for property that is not in the object. Here is my code:
function checkObj(obj, checkProp) {
// Only change code below this line
if(obj.hasOwnProperty(checkProp)){
return obj[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_15_4) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/13.1 Safari/605.1.15.
Challenge: Testing Objects for Properties
Link to the challenge:
It checks out all the properties that are in the object, but the two that are not in there. I went on get help >>get a hint and my code looks just like the one in the hint, but it doesn’t work. Can anyone explain why is this happening?
Happy coding!