Tell us what’s happening:
My initial solution created an array which I then called .reduce()
on to sum the even valued terms. But that would not pass. I then used the code shown here to pass the challenge. However shouldn’t the first returned value be 44 and not 188; as 144 is the 11th term and shouldn’t be summed, or?
I am a math noob but am really confused by this.
Your code so far
function fiboEvenSum(n) {
let a = 1
let b = 1
let c
let num = 0
while ( n >= 0) {
c = a
a = a + b
b = c
n--
if (c % 2 == 0) {
num += c;
}
console.log(num)
}
return num;
}
fiboEvenSum(10);
Your browser information:
User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/71.0.3578.98 Safari/537.36
.
Link to the challenge: