Freecodecamp: Running test with a comment at the end makes the test fail.

Created on 31 Jul 2020  路  3Comments  路  Source: freeCodeCamp/freeCodeCamp


Describe your problem and how to reproduce it:
Running the test will fail if you have anything commented after the code.
Deleting the comment line allows us to pass the test.
The presence of a comment should not affect the output of the test.

(function() {
  console.log("A cozy nest is ready");
})();
// makeNest();

Add a Link to the page with the problem:
Object Oriented Programming: Understand the Immediately Invoked Function Expression (IIFE)
https://www.freecodecamp.org/learn/javascript-algorithms-and-data-structures/object-oriented-programming/understand-the-immediately-invoked-function-expression-iife

Tell us about your browser and operating system:

  • Browser Name: Chrome
  • Browser Version: Version 84.0.4147.105 (Official Build) (64-bit)
  • Operating System: Catalina 10.15.6

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

learn

Most helpful comment

@LazaroFilm thanks for reporting this, it's definitely not working as intended.

@JoshuaPelealu, that's my assessment, too. A PR would be very welcome.

All 3 comments

It looks like this is caused because the test is removing every whitespace and make the code one line, then test it with a regex, that test if the string ends with a ) parentheses. This might lead to some errors in which people comment the uneeded code.

This can be easily fixed by changing the regex string from instead of testing if it ends with a () it will test if it's an IIFE function. So it will ignore anything after the IIFE. I can do this.

@LazaroFilm thanks for reporting this, it's definitely not working as intended.

@JoshuaPelealu, that's my assessment, too. A PR would be very welcome.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

kokushozero picture kokushozero  路  3Comments

danielonodje picture danielonodje  路  3Comments

MichaelLeeHobbs picture MichaelLeeHobbs  路  3Comments

raisedadead picture raisedadead  路  3Comments

bagrounds picture bagrounds  路  3Comments