fix(curriculum): support arrow functions in fibonacci recursion test#66920
Draft
lakshay122007 wants to merge 1 commit intofreeCodeCamp:mainfrom
Draft
fix(curriculum): support arrow functions in fibonacci recursion test#66920lakshay122007 wants to merge 1 commit intofreeCodeCamp:mainfrom
lakshay122007 wants to merge 1 commit intofreeCodeCamp:mainfrom
Conversation
| 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*\(/)); |
Contributor
There was a problem hiding this comment.
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Checklist:
mainbranch of freeCodeCamp.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.