Freecodecamp: arrow function without curly braces fail IIFE test

Created on 14 Apr 2020  路  3Comments  路  Source: freeCodeCamp/freeCodeCamp


Describe your problem and how to reproduce it:
ref: #35573
The code below does not pass as an anonymous immediately invoked function expression (IIFE).
(()=> console.log("A cozy nest is ready"))();

Add a Link to the page with the problem:
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: Google Chrome
  • Browser Version: Version 80.0.3987.163 (Official Build) (32-bit)
  • Operating System: Windows 10 Enterprise Build 18363.752

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

help wanted learn needs help for triage

All 3 comments

Thanks for bringing this to our attention @piouson. We do want valid answers like yours to pass.

This seems like a pretty simple fix -- the regex in the current tests expect opening and closing curly braces ({ and }), so we can make those optional with the ? quantifier.

I believe the tests should be changed to

    testString: assert(/\((function|\(\))(=>|\(\)){?/.test(code.replace(/\s/g, "")));

and

    testString: assert(/}?\)\(\)/.test(code.replace(/\s/g, "")));

Would you be interested in submitting a PR to fix this?

Thank you @scissorsneedfoodtoo absolutely very interested, this will be my first PR!

Awesome, thank you for creating a PR so quickly! We'll review it as soon as possible.

Was this page helpful?
0 / 5 - 0 ratings