Here's the code to calculate the Fibonacci series in JS code:

BY Best Interview Question ON 20 Jun 2020

Example

var the_fibonacci_series = function (n)
{
  if (n===1)
  {
    return [0, 1];
  }
  else
  {
    var a = the_fibonacci_series(n - 1);
    a.push(a[a.length - 1] + a[a.length - 2]);
    return a;
  }
};

console.log(the_fibonacci_series(9));

Suggest An Answer