Fooling the challenge test

Hello, this is my first post on this forum. I was amazed at this actually working and want to know if this is something that is known to the developers of FCC or is it just a bug? :slight_smile:

That’s not a bug, that’s just how testing works.

In fact, lots of testing tutorials online suggest writing something like that to pass a test first to ensure your testing works :slight_smile: The idea is to the. Refactor your code so that the tests still pass when the function arguments are different.

You can pass every test on FCC by hardcoding test responses like you have, and you can pass every project by pasting the URL of your favourite cat picture (in the short term at least). Not particularly fruitful, though…

Edit

Ideally the test runner would have enough cases to dissuade this type of ‘hack’ though.

1 Like

That’s not a bug. Merely how tests work. They care about the result, not the implementation.

In fact, returning the exact expected result is one step in a recommended test driven development workflow …

FCC is based on the honor system. They expect a person to honestly do the work. (Otherwise why be here?)

Ultimately, if you decide to push through and do the non profit section, your work will be checked.

Edit: Whoa … I hadn’t posted my response and when I came back and did so I thought my avatar was messed up for a minute. Very similar thoughts @JacksonBates!

2 Likes

I was just curious to know if it was “working as intended” or not. I do want to push through the course in a normal manner, that’s not an issue for me. :smiley: Thanks for the feedback.

The question should be, ‘Why does this work? What did I do to make it pass?’ Cheating a test is a good lesson in itself :wink: