Fibonacci sequence and nth number with reduce()
A short review;

I prefer fat arrow syntax =&gt; for inline functions
Its a good exercise to code this with reduce but it is definitely not the best option for production code. (That would be a non-recursive old skool loop)
The modern approach to Fibonacci numbers has them start with [0,1,1] not [1,1]
If you have control over what the function returns, then I would just return the sequence. It is trivial for the caller to get the last value in the array

Please find below a counter proposal, I like that it support both the old and new style sequence.


function buildFibonnaciSequence(n){
  const start = [0,1];
  //Recursion exit lane
  if(n &lt;= 1){
    return [start.slice(0,n+1), start[n]];
  }
  //Recurse
  const priorSequence = buildFibonnaciSequence(n-1);
  //Build return value
  const nValue = priorSequence[0][n-2] + priorSequence[0][n-1];
  return [[...priorSequence[0], nValue], nValue];
}

console.log(buildFibonnaciSequence(0));
console.log(buildFibonnaciSequence(1));
console.log(buildFibonnaciSequence(5));
console.log(buildFibonnaciSequence(45));