when helping anther Camper[@VaseJS] on Sum All Odd Fibonacci Numbers I tried this code and passed the test but when I tried on anther browser it didn’t pass
function subFibs(num) {
var a = 0,
b = 1,
f = 1,
odds = [],
fibs = [1];
//create Fib Sequence
for(var i = 0; f <= num; i++) {
f = a + b;
if(f % 2 !== 0) {
fibs.push(f);
}
a = b;
b = f;
//was getting one number too high before use of if statement
if(a + b > num) {
break;
}
}
//reduce odd fibs
odds = fibs.reduce(function(prev, curr) {
return prev + curr;
});
console.log(odds);
return odds;
}
subFibs(3);