Sum of Primes = Can't quite understand what i am doing wrong

Sum of Primes = Can't quite understand what i am doing wrong
0.0 0

#1


Couldn’t figure out how to delete the post.

Thank you @alhazen1 for your response! Super appreciate it :slight_smile:


#2

Hi,
I see a few things.

You don’t seem to be returning the result of your filter()reduce() calculation. That calculation is stored back into primeArray but primeArray is never returned so you are getting results of undefined. Fix that and you will get a numeric answer (but not the correct answer).

I don’t think your filter for primes is working as expected. Looks like you are filtering out evens which is not the same thing. If you comment out your call to reduce() but leave filter() intact you will see that the return value then is just an array of odd numbers, not primes.

You probably will need to research calculating primes. One method is Sieve of Eratosthenes.

This is a difficult challenge so it might take some time to solve. Good luck on this!