sumFibs(75024) Test is failing rest are passing

Tell us what’s happening:

The following test is failing:
sumFibs(75024) should return 60696.
and I don’t understand why. It is saving the number in the Fibonacci sequence: 135721

Your code so far


function sumFibs(num){
    let ans = 0;
    let first = 0; 
    let second= 1;
    let result = 1;
    while  (result <= num ){
      ans = first + second;
      first = second;
      second = ans;
      if (ans % 2 !== 0){
      result = result + ans
      console.log(result)
    }
    
    }
    
    return result
    }
    sumFibs(75024);
            

Your browser information:

User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/73.0.3683.103 Safari/537.36.

Link to the challenge:
https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/intermediate-algorithm-scripting/sum-all-odd-fibonacci-numbers

you are going one past the loop and giving the answer for 75025, because of this condition

      if (ans % 2 !== 0){
      result = result + ans
      console.log(ans, result)
    }

Compare ans with result in your if statement, since your upper loop condition does not terminate when ans > 75024 it returns the next answer, you need to figure out how to alter the condition to accommodate both 75025 and 75024. Hint: It is a simple one liner, to modify the expression of your condition in the above snippet.