Hi,
I have the below code for Sum All Odd Fibonacci Numbers problem and it seems to work for every number except the last one. Could someone tell me where I have gone wrong?
Here’s my code:
function sumFibs(num) {
var i = 1;
var base = [1,1];
while(i<=base.length){
var nextDigit = base[i]+base[i-1];
if(nextDigit < num){
base.push(nextDigit);
}
i++;
}
var sum = base.filter(function(x){return x % 2 !== 0;});
return sum.reduce(function(a,b){return a+b;});
}
sumFibs(75025);
Thanks!