Sum All Odd Fibonacci Numbers (issue w/ largest num)

Tell us what’s happening:

Hey, thanks for looking at my code! I got every other check mark for this challenge except the largest number, which is 75024. I have a feeling it has something to do with the conditional I set - "&& ans<num’

At a loss for what to look at, really appreciate the help!

Your code so far


function sumFibs(num) {
  let arr = [1, 1];
  let ans = 0;
  let odds = [];
  for (let i = 0; i < num; i++) {
      arr.push(arr[i] + arr[i+1]);
  }
  for (let i = 0; i<arr.length; i++) {
    if(arr[i] % 2 !== 0 && ans<num) {
      odds.push(arr[i]);
      ans = odds.reduce(function(a, b) {
      return a + b;
    });
    }
  }
  console.log(ans)
  return ans;
}
sumFibs(75024);

Link to the challenge:

Hi.
Yes. You have a good feeling. :slight_smile:
arr[i]<=num