Tell us what’s happening:
Whats wrong with my code Please help me out…
It only passess the second test case that for fiboEvenSum(23)
Your code so far
function fiboEvenSum(n) {
var a = 0;
var b = 1;
var d = 0;
var sum = 0;
for(var i = 0 ; i < n; i++){
d = a + b;
a = b;
b = d;
if(d%2==0){
sum += d;
}
}
return sum;
}
console.log(fiboEvenSum(10));
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/69.0.3497.100 Safari/537.36
.
Link to the challenge:
https://learn.freecodecamp.org/coding-interview-prep/project-euler/problem-2-even-fibonacci-numbers