+ 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);
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
+ 1
@Eze thanks
0
can you link the code via code link instead of posting the code