Build an Nth Fibonacci Number Calculator - Build an Nth Fibonacci Number Calculator

Tell us what’s happening:

Failed test case #11 “You should not use recursion in your code”

No recursion is used tho…

Your code so far

const fibonacci = (n) => {
  let sequence = [0, 1]

  for (let i = 2; i <= n; i++) {
    sequence.push(sequence[i - 1] + sequence[i - 2])
  }

  return sequence[n]
}

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/146.0.0.0 Safari/537.36

Challenge Information:

Build an Nth Fibonacci Number Calculator - Build an Nth Fibonacci Number Calculator

Thank you for helping make FCC better. Bugs can be reported as GitHub Issues. Whenever reporting a bug, please check first that there isn’t already an issue for it and provide as much detail as possible.

Hello, test case 11 checks out for me but test cases 6-10 don’t. My code is the same as Wong’s.

I’ve tested the code with a different playground, but any tests for n > 1 return undefined.

Edit: something with the iteration didn’t check out, found the solution a short while ago.

freeCodeCamp’s test runner sometimes flags certain patterns as recursive even when they technically aren’t, usually because it’s scanning for specific function call signatures rather than actual call stack behavior. Worth double checking if you’re calling the function by name anywhere inside itself, even indirectly. Also try renaming the function to something generic just to rule out any name-matching false positive in the checker.