Skip to content

fix(curriculum): allow arrow functions in factorial calculator - #69520

Merged
a2937 merged 2 commits into
freeCodeCamp:mainfrom
wunianze666-netizen:fix/factorial-calculator-function-forms
Aug 17, 2026
Merged

a2937 merged 2 commits into
freeCodeCamp:mainfrom
wunianze666-netizen:fix/factorial-calculator-function-forms

Conversation

@wunianze666-netizen

@wunianze666-netizen wunianze666-netizen commented Aug 13, 2026 •

Copy link
Copy Markdown
Contributor

Checklist:

Closes #69484

Summary

  • replace the Function.prototype.toString() regex with the curriculum Explorer AST helper
  • validate the factorialCalculator parameter count independently of function syntax

Why

The previous regex only matched a named function declaration, so valid function expressions and arrow functions failed the parameter hint. Inspecting the parsed function node makes the test accept all three forms while still requiring exactly one parameter.

Validation

  • pnpm exec vitest run --project test with FCC_CHALLENGE_ID=66c07238b01053abaf812065 (6 passed)
  • pnpm -F @freecodecamp/curriculum lint-challenges
  • pnpm exec prettier --check curriculum/challenges/english/blocks/lab-factorial-calculator/66c07238b01053abaf812065.md

@wunianze666-netizen
wunianze666-netizen requested review from a team as code owners August 13, 2026 10:47
@github-actions github-actions Bot added scope: curriculum Lessons, Challenges, Projects and other Curricular Content in curriculum directory. deprioritized PR reviews are deprioritized; lacks productive input and ignores codebase best practices. labels Aug 13, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Hi there,

Thanks for opening this pull request.

The automated checks found some issues:

Checklist: The PR description is missing the required checklist or some of its items are not completed:

  1. The Checklist: heading is present in the PR description.
  2. The checkbox items are ticked (changed from [ ] to [x]).
  3. You have actually completed the items in the checklist.

Please edit your PR description to include the following template with the checklist items completed.

Checklist:

<!-- Please follow this checklist and put an x in each of the boxes, like this: [x]. It will ensure that our team takes your pull request seriously. -->

- [ ] I have read and followed the [contribution guidelines](https://contribute.freecodecamp.org).
- [ ] I have read and followed the [how to open a pull request guide](https://contribute.freecodecamp.org/how-to-open-a-pull-request/).
- [ ] My pull request targets the `main` branch of freeCodeCamp.
- [ ] I have tested these changes either locally on my machine, or GitHub Codespaces.

<!--If your pull request closes a GitHub issue, replace the XXXXX below with the issue number.-->

Closes #XXXXX

<!-- Feel free to add any additional description of changes below this line -->

Join us in our chat room or our forum if you have any questions or need help with contributing.

@github-actions github-actions Bot removed the deprioritized PR reviews are deprioritized; lacks productive input and ignores codebase best practices. label Aug 13, 2026

@imsomilg imsomilg left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Always try to maintain good code readability; in this case, you can achieve it by destructuring. Additionally, please use an optional chaining check on factorialCalculator, as parameters will throw a TypeError if the camper never defines factorialCalculator.

Also, could you please update your PR title? It's currently a bit vague. It's best to briefly describe the exact issue you are resolving, especially since the title will become the commit message once the PR is merged.

@imsomilg imsomilg added status: waiting review To be applied to PR's that are ready for QA, especially when additional review is pending. js v9 cert This is for the JS V9 certification. status: waiting update Is awaiting update, after feedback or request for changes and removed status: waiting review To be applied to PR's that are ready for QA, especially when additional review is pending. labels Aug 13, 2026
@wunianze666-netizen wunianze666-netizen changed the title fix(curriculum): accept all factorial function forms fix(curriculum): allow arrow functions in factorial calculator Aug 14, 2026
@wunianze666-netizen

wunianze666-netizen commented Aug 14, 2026 •

Copy link
Copy Markdown
Contributor Author

Updated the test to destructure factorialCalculator and use optional chaining before reading parameters, so an undefined function produces an assertion failure instead of a TypeError. I also updated the title to describe the arrow-function issue directly. The targeted curriculum tests (6/6), challenge lint, and Prettier check all pass.

@imsomilg imsomilg left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 🚀

@imsomilg imsomilg added status: waiting review To be applied to PR's that are ready for QA, especially when additional review is pending. and removed status: waiting update Is awaiting update, after feedback or request for changes labels Aug 14, 2026
@a2937
a2937 enabled auto-merge (squash) August 15, 2026 21:08

@majestic-owl448 majestic-owl448 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @wunianze666-netizen. Congrats on your first pull request (PR)! 🎉

Thank you for your contribution to the page! 👍
We are happy to accept these changes and look forward to future contributions. 📝

@a2937
a2937 merged commit 27786f4 into freeCodeCamp:main Aug 17, 2026
16 checks passed
@github-actions github-actions Bot locked as resolved and limited conversation to collaborators Aug 17, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

js v9 cert This is for the JS V9 certification. scope: curriculum Lessons, Challenges, Projects and other Curricular Content in curriculum directory. status: waiting review To be applied to PR's that are ready for QA, especially when additional review is pending.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Factorial Calculator only accepts regular function

4 participants