Basic JavaScript: Testing Objects for Properties: Can't figure out what's wrong

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?

its the “f” in found

not sure what you mean by that. could you elaborate?

I am trying to be a little bit vague so you can work it out, but look at your else statement and read the test instructions, then look at the word “found”

I’m so stupid. Cant believe it was so stupid)))) Thanks!!! 4 hours waisted)))

I hope I won’t be making that mistake anymore))) good lesson.

no problem , try not to think of it as wasted time because you will find these tiny errors are often the reason the test does not pass, so remembering that will help as you move further on

Cheers

Coding requires you to pay attention to detail… :grinning: Happy coding!

thanks a ton :smile: