Tell us what’s happening:
Describe your issue in detail here.
What’s happening?
Don’t work
Your code so far
function sumFibs(num) {
let fNum = [0,1,1];
for (let i = 1; i <= num; i ++) {
let nextNum = fNum[fNum.length -1] + fNum[fNum.length-2];
if (nextNum <= num) {
fNum.push(nextNum);
const oddNum = fNum.filter((n) => n % 2 !== 0);
const sumFib = oddNum.reduce((a,b) => a + b,0);
return sumFib;
}
}
}
sumFibs(10);
Your browser information:
User Agent is: Mozilla/5.0 (Linux; Android 10; K) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36
Challenge Information:
Intermediate Algorithm Scripting - Sum All Odd Fibonacci Numbers