Given a number: max, find all the primes that are smaller or equal to it. Sum of them up, then return the sum.
Get/write yourself a function to check if a number is a prime. Then use it to check all numbers equal or smaller than the max
Then the challenge would essentially become: how do you implement the algorithm to check if a number is prime?
Once you have found a prime number, you can pretty much eliminate a lot of not primes by multiplying that prime with a series of numbers.
Ex: starting from number 2, you can 2X2=4 which eliminates 4, 2X3=6 which eliminates 6, 2X4 which eliminates 8, etc...
Wikipedia's article on Sieve Of Eratosthenes
Go to: lib/spec.js change 'xit' to 'it' to see what would happen if generating all the primes within 1 million
Khan Academy Explanation of Sieve of Eratosthenes
Prime Numbers & The Sieve of Eratosthenes
Researcher Modifies Sieve of Eratosthenes To Work With Less Physical Memory Space