Freecodecamp: Possibly unclear instructions on "Check for the Presence of an Element with IndexOf"

Created on 2 Jun 2020  路  4Comments  路  Source: freeCodeCamp/freeCodeCamp


Describe your problem and how to reproduce it:
The tests call for the function to return true or false. I ran into a user on the forums that was failing to get the tests to pass because they were returning "true" and "false" as strings, rather than boolean values.

I wonder if the instructions should be made a little more specific to clarify that the function needs to return boolean values.

Add a Link to the page with the problem:
Check for the Presence of an Element with indexOf()

Tell us about your browser and operating system:

  • Browser Name: Chrome
  • Browser Version: Version 83.0.4103.61
  • Operating System: Windows 10 Home v 1909

If possible, add a screenshot here (you can drag and drop, png, jpg, gif, etc. in this box):
image

help wanted learn

All 4 comments

Whilst I can understand the confusion, the general adopted format has been:

  • What is within the code tags is exactly what needs to be returned

In other exercises, if the user is asked to return a string, it should be

... return "some string" ...

I say should be, because I just encountered another exercise where the test string was not following this format, but it is likely to be fixed.

That format makes complete sense to me.
The only reason I bring this up is that I know learning to code can be a frustrating experience for some, and an opportunity to eliminate potential confusion and alleviate some of the self-generated stress seems like a good move.

How about catching this with a test?

quickCheck should return a boolean (true or false) not a string ("true" or "false")

I like that idea. It provides a little extra clarity on why the test is failing for the user's code.

Was this page helpful?
0 / 5 - 0 ratings