Challenge Name
Sum All Odd Fibonacci Numbers has an issue.
Issue Description
So I tried the code within my console, it giving back all the correct answer, however the freecodecamp testing suite is showing that I do not have the correct answer.
These are the values I am supplying to my function, currently using the latest
version of visual code studios console to test them. They return the answer as
below but for the FCC test says that the values returned are not correct.
sumFibs(4); // should return 5
sumFibs(75024); // should return 60696;
sumFibs(75025); // should return 135721;
Browser Information
User Agent is: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:54.0) Gecko/20100101 Firefox/54.0
.
Screenshot
Your Code
let a = 0;
let b = 1;
let arr = [];
function sumFibs(num) {
if (num == 1)
return 1;
if (a <= num || a == 1) {
arr.push(a);
b += a;
a = b - a;
return sumFibs(num);
}
return arr.filter(x => { return x % 2 !== 0; }).reduce((a, b) => { return a + b; });
}
sumFibs(1);
```<img src="//cdck-file-uploads-global.s3.dualstack.us-west-2.amazonaws.com/freecodecamp/original/3X/c/5/c5c4e39b747b44b5559bed10f7d2076ff7641a77.png" width="690" height="388">