Hi, I’m trying to solve “Sum All Primes” challenge. I decided to use Sieve of Eratosthenes as part of my solution. Here is the Wikipedia article about this method.
I’m not asking if my implementation is good, if it isn’t I’ll figure it out myself. Question is why I’m getting “TypeError: acc.push is not a function” message, when acc is passed as empty array.
Code:
acc is accumulator. It’s kind of optimization to recursive calls. Problem is that I pass the initial value as empty array, and get error that array has not method “push()”? That confuses me.
Thank you. I used to do some python earlier, arr == [] is totally ok in py world. But, error is still the same “TypeError: acc.push is not a function” after i changed my condition as you suggested.