I’ve looked at the challenge after your post, and certainly this challenge has some quirks in it.
Basically to get the correct output given by each test case, you need to take away the first 2 sequences from typical Fibonacci sequence.
Consider the first ten Fibonacci sequence (that starts from 1)
[1, 1, 2, 3, 5, 8, 13, 21, 34, 55]
Here, the even sum is 2 + 8 + 34 = 44
. But this is far from the given test value, which demands 188
.
Now, consider the first twelve Fibonacci sequence
[1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144]
Here, the even sum is 2 + 8 + 34 + 144 = 188
So, feboEvenSum(10)
actually requires the first twelve sequence.
Does this pattern continue with the other test cases? Yes.
Try it out in an online editor that supports ES6 generator. e.g) repl.it, JSFiddle
function *fib() {
let a = 0, b = 1
for(let tmp; ;) {
yield b
tmp = a
a = b
b += tmp
}
}
let seq = (gen) => (n) => {
let g = gen(), res = []
while(--n >= 0) res.push(g.next().value)
return res
}
let fibseq = seq(fib)
let even = (n) => n % 2 === 0
let sum = (a, b) => a + b
let sumEvenFib = (n) => fibseq(n).filter(even).reduce(sum)
console.log(sumEvenFib(10))
console.log(sumEvenFib(11))
console.log(sumEvenFib(12))
console.log(sumEvenFib(23))
console.log(sumEvenFib(24))
console.log(sumEvenFib(25))
console.log(sumEvenFib(43))
console.log(sumEvenFib(44))
console.log(sumEvenFib(45))
I wrote the code such that OP won’t likely to understand to avoid spoiling the direct solution.
The conclusion is that the challenge is not well described and has weird Fibonacci sequence definition.