JavaScript - Testing Objects for Properties

Continuing the discussion from freeCodeCamp Challenge Guide: Testing Objects for Properties:

This is the only problem I am stuck on in the JavaScript section. Looks like this post was updated recently but the solution no longer works. What am I doing wrong here?

This is the solution provided that does not pass:

function checkObj(obj, checkProp) {
  if (obj.hasOwnProperty(checkProp)) {
    return obj[checkProp];
  } else {
    return "Not Found";
1 Like

The solution in the first post still works if you just want to copy-paste the answer instead of fixing your own answer.

If you want help fixing your answer, please post what you’ve written here and we can help you out!

Thanks! This always happens. As soon as I post I figure it out. I’d delete the post but I don’t have permission. Thanks! - Will

The solution you added to your edited post does pass the challenge. As such, I added spoiler tags to it.

I’m not sure what you are seeing that indicates that this solution does not pass the challenge.

Something’s wrong with the system here. This happened few times already where the solutions suggested here are exactly what I’m typing, but it still gives error, but when I copy and paste the solution from here it works. why is that???
I’ve repeatedly examined and compared line by line to see what could be wrong from what I’m typing and I see exactly the same even the spaces but for some reason is still doesn’t work and it only works with the copied code solutions from here…very strange

First, if you don’t add anything to the original question, please open a new topic.

Second… well… I mean “you” say everything is identical. But code can be very sensitive to even the tiniest mistake.
I’ve seen myself running into the issue you describe, only to see one letter being wrong, or one bracket missing or just one other tiny mistake.
Just the other day someone was stuck on a challenge because they wrote “scr” instead of “src” and it took me a couple minutes until I figured their mistake and I am by no means a beginner.

Heck I remember I once put my failing solution and the actual solution into a string-comparison program just to figure out where it went wrong.

In other words, we’d need to at least see your failing but supposedly correct code, to see if it’s really flawless. Because frankly, chances are low. Whatever is running in the background for these tests, is but some basic hidden JavaScript. There is little reason to think it has the potential to fail on working code.
Like yeah, there are examples where a browser will understand html but JavaScript won’t, because JS is case-sensitive. But that’s the only time I remember someone posted actual working code, that failed the tests.

1 Like

Please don’t hijack the threads of other forum members. If you have a question about a specific challenge as it relates to your written code for that challenge, just click the Ask for Help button located on the challenge. It will create a new topic with all code you have written and include a link to the challenge also. You will still be able to ask any questions in the post before submitting it to the forum.

Thank you.