Interestingly, all test cases are passing except the third one. I tried the code in hint section but the advanced solution, too, doesn’t pass a couple tests.
Can anyone please tell me where is the bug?
Your code so far
function sumFibs(num) {
function fib (n){
if (n===1||n===2){return 1;}
return fib(n-1)+fib(n-2);
}
var sum=0;
for(let i=1;fib(i)<=num;i++){
if((fib(i))%2!==0){
sum=sum+fib(i);
}
}
return sum;
}
console.log(sumFibs(4000000));
Your browser information:
User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/69.0.3497.100 Safari/537.36
.
Link to the challenge: