I’ve been debugging this… The story is totally inconsistent, either we get the SUM of all odd fibonacci numbers for a total SUM less than or equal than NUM, or we get that SUM + the next odd number that’ll make SUM to overflow the NUM limit.
We can’t have it both. Most of the tests seem to check for the overflowed result. However, sumFibs(75024) expects 60696. Makes no sense.
Tell us what’s happening:
Describe your issue in detail here.
**Your code so far**
function sumFibs(num) {
if (num < 2) { return 2 };
let arr = [1, 1];
let acc = 2;
for (let i = 0; i < 1000; i++) {
arr.push(arr[i] + arr[i + 1]);
if (arr[i + 2] % 2) {
acc += arr[i + 2];
if (acc > num)
break;
};
};
console.log(acc);
return acc;
};
sumFibs(75024);
sumFibs(75025);
**Your browser information:**
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/101.0.4951.41 Safari/537.36 Edg/101.0.1210.32
Challenge: Sum All Odd Fibonacci Numbers
Link to the challenge: