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