Skip to content

fix(curriculum): support arrow functions in fibonacci recursion test#66920

Draft
lakshay122007 wants to merge 1 commit intofreeCodeCamp:mainfrom
lakshay122007:fix/fibonacci-recursion-test
Draft

fix(curriculum): support arrow functions in fibonacci recursion test#66920
lakshay122007 wants to merge 1 commit intofreeCodeCamp:mainfrom
lakshay122007:fix/fibonacci-recursion-test

Conversation

@lakshay122007
Copy link
Copy Markdown
Contributor

Checklist:

Closes #66910

Description

The current recursion check assumes the function is written using a function declaration (function fibonacci(...) { ... }).

This change updates the check to use fibonacci.toString() instead of relying on a specific function syntax. This ensures the recursion detection works for both function declarations and arrow functions, fixing the false failure.

@lakshay122007 lakshay122007 requested review from a team as code owners April 13, 2026 16:32
@github-actions github-actions bot added the scope: curriculum Lessons, Challenges, Projects and other Curricular Content in curriculum directory. label Apr 13, 2026
@lakshay122007 lakshay122007 marked this pull request as draft April 13, 2026 17:31
const bodyMatch = __helpers.removeJSComments(code).match(/function\s+fibonacci\s*\([^)]*\)\s*\{([\s\S]*)\}/);
assert(bodyMatch && !bodyMatch[1].match(/\bfibonacci\s*\(/));
const fnString = __helpers.removeJSComments(fibonacci.toString());
assert(!fnString.match(/\bfibonacci\s*\(/));
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.

at least one is found, it's the function name, please notice the use of !bodyMatch[1].match(/\bfibonacci\s*\(/) in the previous version of the test

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

scope: curriculum Lessons, Challenges, Projects and other Curricular Content in curriculum directory.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bug - Build an Nth Fibonacci Number Calculator (javascript-v9)

2 participants