Tell us what’s happening:
I can’t get the final test sumFibs(75025)
to return 135721, even though the other numbers tests as they should.
when I can get it correct though, all the other tests comes out as wrong
Your code so far
function sumFibs(num) {
let nums = [0,0,1,0]
for(nums[2]; nums[2] < num; nums[2]){
if(nums[2] % 2 === 1){
(nums[3] += nums[2])
}
nums[0] = nums[1],
nums[1] = nums[2],
nums[2] = nums[0] + nums[1]
}
return nums[3]
}
let result = sumFibs(75026);
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.141 Safari/537.36
.
Challenge: Sum All Odd Fibonacci Numbers
Link to the challenge: