the guide does not have any other working code so here is another simple hair splitter that uses for loop
hope this will help better visualization of the Fibonacci process:
function sumFibs(num) {
var i,ii,iii=2,y=1;
for (i=0;i<=num; ){
i<3 ? ii=1 : ii=iii;
i%2===0? "" : y=y+i ;
iii=i; //forward reference to be used by ii
i=i+ii; //incrementing i to loop
}
return y;
}
sumFibs(10);
==================
the solution had to be visualized using this mockup pattern:
where 1, 1, 2, 3, 5 and 8... as trail pattern
i, ii = iv
1 (first number in fibonacci)
iii 0, 1 = 1 (second number which is sum of iterator i and ii)
iii 1, 1 = 2
iii 2, 1 = 3 (ii is 1 until i is >=3)
iii 3, 2 = 5
iii 5, 3 = 8
@ieahleen sorry mods for sharing code … I hope that this may shed some light…