The Console isn't Accepting My Solution, Even though I'm Correct

I provided a way different way to solve the challenge on “BASIC DATA STRUCTURE: CHECK IF AN OBJECT HAS A PROPERTY”, but the console isn’t allowing me to progress. The images below shows my own way of solving the problem.

After solving the task my own way, I went on to check the hint and I saw a different way of solving the problem. It was until I solved the problem using the hint, that I was approved to go on to the next challenge.
It might not be big deal, but I’m not happy that the second requirement to pass the task was not accepted and the console didn’t approve of my answer.

Although, I’m through with this challenge, I need someone to explain to me why my solution was not approved.

Can you please share your code, rather than a screenshot?

You can use the “Ask for help” button on the challenge.

Don’t change the function, the comments shows you where to put your code. You can’t just add another parameter. Also, what is kanada anyway? I can see you’re passing the string “Jeff” into the function inside the console.log(), but that won’t work. For one, what about all the other users? Second, the test isn’t using that function call, it’s just for you to test with.

kanada is a property in the object.

The error, showing up there came up after I clicked the “run the test” button.
Before then, the code return the correct results for each.
ONLy I was not allowed to progress.

Because you are not correct.

  1. the function should work with just the users object being passed. ( Alan , Jeff , Sarah , and Ryan) need to be somehow handled inside the function.
  2. in the tests, FCC will run the function passing an object, which will sometimes have all the names present and sometimes won’t.

So essentially your “solution” solves a problem that you were not asked to solve.

1 Like

Well that explains everything… thank you very much @ChadKreutzer

1 Like