Stuck on the Fibenacci challenge

function sumFibs(num) {

let arr = [1,1];

while (num > 0){

let fibNum = arr[arr.length-1] +arr[arr.length-2];

if (fibNum <= num ){

arr.push(fibNum);
}
  num --;
}

let oddSeq = arr.filter( val => 
{
return val%2 !== 0;
}
)

console.log(oddSeq);

let result = oddSeq.reduce((item, val) => {

return item+val;

})

return result;

}

console.log(sumFibs(75024));

My code so far

I can’t seem to get why the last test won’t pass.

Take a look at this: your fibNum loop decreases the value of the num parameter, so you’re not catching the last fibonacci number (75025 is a fibonacci number)

1 Like

Bless you! I just needed to make a counter. Thank you so much!

2 Likes

Very glad I could help! Make sure you take a moment to celebrate your success!

1 Like