You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Factorial Calculator only accepts regular function #69484
Enter code from the above post. It does not pass the tests.
Recommended fix or suggestions
Fix the tests to allow both an arrow function or regular function or add a note to the instructions letting users know the tests will only accept a regular function.
Hi @maintainers, I've reproduced this. The test uses factorialCalculator.toString() to check the function was declared with an argument, but that only works for named function declarations: arrow functions' .toString() doesn't include the variable name, so valid arrow-function solutions fail. I opened a fix in #69488 (swaps the toString-regex check for factorialCalculator.length === 1, which works for both styles). Would appreciate a triage when you get a chance so it can move forward, thanks!
The test code for the following hint should be updated to support all three types of functions: function declarations, function expressions, and arrow functions.
The factorialCalculator function should take a number as an argument.
Instead of regex, we can use the allFunctions and parameters AST helpers. You can check the docs for help with implementing this.
Activity
jacobptnguyen commentedon Aug 11, 2026
Hi @maintainers, I've reproduced this. The test uses factorialCalculator.toString() to check the function was declared with an argument, but that only works for named function declarations: arrow functions' .toString() doesn't include the variable name, so valid arrow-function solutions fail. I opened a fix in #69488 (swaps the toString-regex check for factorialCalculator.length === 1, which works for both styles). Would appreciate a triage when you get a chance so it can move forward, thanks!
imsomilg commentedon Aug 13, 2026
The test code for the following hint should be updated to support all three types of functions: function declarations, function expressions, and arrow functions.
Instead of regex, we can use the
allFunctionsandparametersAST helpers. You can check the docs for help with implementing this.jacobptnguyen commentedon Aug 14, 2026
Hi @imsomilg, I implemented the changes you requested. Please review the PR, thank you.