Hi guys, I have found a way of solving this algorithm using recursion, but I can’t submit it to the tests because some of the arguments are too high and it exceeds the maximum call stack.

I understand that recursion isn’t really the best method for this fibonacci exercise, but for the purpose of being able to implement memoization, would someone be able to help me understand it?

I get that I’m trying to get the function to cache it’s answers as it progresses, but I don’t understand how to implement that in my function?

Thanks guys!

**Your code so far**

```
function sumFibs(num) {
let fib = ((len, arr = [1,1]) => {
if (arr.length >= len) {
return arr.filter(el => el % 2 !== 0 && el <= len)
.reduce((acc, val) => acc + val, 0);
}
arr.push(arr[arr.length - 2] + arr[arr.length - 1]);
return fib(len, arr);
});
return fib(num);
}
sumFibs(4);
```

**Your browser information:**

User Agent is: `Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/69.0.3497.100 Safari/537.36`

.

**Link to the challenge:**

https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/intermediate-algorithm-scripting/sum-all-odd-fibonacci-numbers/