Hi all, I am going through the JavaScript courses here and I feel like I’m picking them up pretty quickly. This challenge gave me a hard time but I was able to figure it out. I am posting here because the challenge itself is very confusing. I don’t know if it was intended to be. When you run the tests on your code it gives some pretty wild error messages. I had pretty much figured it out but I had spelled a variable wrong and didn’t realize. It looked good to me but the tests were asking for crazy things like a variable named “pony”? Needless to say I was pretty confused so I took a look at the solution and realized that the tests weren’t right. I just wanted to share this possible bug
**Your browser information:**
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/95.0.4638.69 Safari/537.36
Sure it is not hard to recreate and it didn’t stop me from completing the challenge.
here is a picture of the tests. It shows all kinds of unrelated objects and properties.
Yeah I did that on purpose to show the test results. Without that “s” in the word “found” the challenge is passed no problem. But the problem is that the tests are supposed to show you were you went wrong. This test shows unrelated information. I figured it was a bug.
This website has been a godsend to me. I plan on completing all of the main courses and I am barely getting through the JavaScript section but have already learned so much. I noticed a bug and thought it would be helpful to point it out. If this is the wrong place for it I apologize.
That was the error in your code, you weren’t returning the correct string.
The “stuff” before that isn’t unrelated information, that’s showing you how the tests called your function. That can be important information to help you figure out why a test is failing.
You will learn about testing in a later certification.
But for me personally, I think it would be kind of pain to write tests for each word that users misspelled in the challenge and return an error message that said, “This word is misspelled.”
So I think the way freeCodeCamp handled it was to say this function call should return the string Not Found
Then users would look at that and say "ohh oops… I have a spelling error.
Instead it tells me that certain things should return a string of pony or kitten or Seattle.
Those didn’t make sense as they are not in the challenge.
I have done hundreds of other challenges and the test info has always been relevant to the challenge. If this was intentional and I am missing something the I apologize.
The tests aren’t checking for spelling mistakes. They test to see if the function returns the correct value based on the inputs. In this case, the tests are showing you the inputs and telling you that your function is not returning the correct value based on those inputs. It is up to you to figure out why
Once you start using a real code editor (such a Visual Studio Code) then you can have the editor help you find these types of mistakes. But the tests are only checking if the correct value is returned for the given inputs.
When I make a spelling mistake in other challenges it usually says something like that variable is not defined or some relevant error. This time it is talking about ponies and kittens. It never mentions ponies or kittens anywhere in the challenge.
Right, your function should be able to take any type of object passed into it and check for whether the checkProp property is found in the object. The tests are showing you the object it passed into the function and the value of the checkProp property that it used for testing. This isn’t information you needed to know before hand.
Ah, I see. I hadn’t noticed that before. Thank you for clarifying. I think the problem was that when I checked my solution all of the user solutions had the ponies and kittens. Maybe it was part of the challenge before it was redone?