+ 1

Can anybody help me with Fibonacci series with JavaScript ?

//Fibonacchi Series in an Array //it says " Unexpected Token ')' " //if you can then please try this code in your Chrome inspect/Source . //I am learning JS and i write code in Chrome\Inspect var n=5; var array=[]; var i; if(n===1) array[0]; else if(n===2) array[0,1]; else{ array[0,1]; for(i=0;i<n;i++) { array.push([array[array.length-2]+array[array.length-1]); } } console.log(array);

16th May 2021, 3:05 PM
Coding San
Coding San - avatar
3 Réponses
+ 1
you are missing a bracket at the end of this line array.push([array[array.length-2]+array[array.length-1]]); but you have errors in your code. check the logic well
16th May 2021, 3:10 PM
Eze
+ 1
@Eze thanks
17th May 2021, 5:05 AM
Coding San
Coding San - avatar
0
can you link the code via code link instead of posting the code
16th May 2021, 3:09 PM
Ananiya Jemberu
Ananiya Jemberu - avatar