All testcases except this one is passing:
Your function is not returning the correct result using our tests values.
Any ideas what I’m doing wrong?
Your code so far
function fiboEvenSum(n) {
let fibArray = [1,2];
for(var i = 2; i <= n+1; i++){
let subTotal = (fibArray[i - 2] + fibArray[i - 1]);
fibArray.push(subTotal);
}
let evenFibArray = [];
let evenSubTotal = 0;
for(var j = 0; j < fibArray.length; j++){
if(fibArray[j] % 2 === 0){
evenSubTotal += fibArray[j];
evenFibArray.push(fibArray[j])
}
}
return evenSubTotal;
}
fiboEvenSum(10);
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/71.0.3578.98 Safari/537.36
.
Link to the challenge: