Tell us what’s happening:
Hello campers,
My code is working as expected and passes all the tests. That is great!
However, I wonder whether is there a way to fill the arr
using a recursion? For now I cannot figure this out.
And I’m also interested whether is my solution good enough?
Your code so far
function sumFibs(num) {
let arr = [0, 1];
let index = 0;
while (num >= arr[index + 1] + arr[index]) {
arr.push(arr[index + 1] + arr[index]);
index++;
}
return arr.filter(num => num % 2).reduce((a,b) => a + b);
}
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:69.0) Gecko/20100101 Firefox/69.0
.
Link to the challenge: