Sum All Odd Fibonacci Numbers - one test failed

sumFibs(75024) should return 60696, but instead it returns 135721.
what am i doing wrong?

function sumFibs(num) {
  let sum = 0;
  let arr = [0, 1];
  
  while(sum <= num){
    if(arr[1] % 2 != 0){
      sum += arr[1];
    }
    let sumArr = arr.reduce((a, b) => a + b);
    arr.shift();
    arr.push(sumArr);
  }
  return sum;
}

sumFibs(75024);

This is not the correct bound.

1 Like

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.