let fib = function(n) {
if (n <= 1) {
return n;
}
else {
return fib(n - 1) + fib(n - 2);
}
}
function sumFibs(num) {
let sum = 0;
let n = 1;
while (fib(n) <= num) {
if ((fib(n) % 2) === 1) {
sum += fib(n);
}
n++;
}
return sum;
}
sumFibs(4000000);
It’s not passing only one test, i.e. the one mentioned… can’t figure out why?