Good evening! Here's our prompt for today.
You're given a number n. Can you write a method sumOfAllPrimes that finds all prime numbers smaller than or equal to n, and returns a sum of them?

For example, we're given the number 15. All prime numbers smaller than 15 are:
2, 3, 5, 7, 11, 13
They sum up to 41, so sumOfAllPrimes(15) would return 41.
Constraints
nwill always be a non zero positive integer <=100000- Expected time complexity :
O(nlogn) - Expected space complexity :
O(n)
Try to solve this here or in Interactive Mode.
How do I practice this challenge?
xxxxxxxxxx34
var assert = require('assert');​function sumOfPrimes(n) { // fill this in return n;}​console.log(sumOfPrimes(7));console.log(sumOfPrimes(15));​try { assert.deepEqual(2, sumOfPrimes(2), 'sumOfPrimes(2) should equal 2');​ console.log('PASSED: ' + '`sumOfPrimes(2)` should equal `2`');} catch (err) { console.log(err);}​try { assert.deepEqual(129, sumOfPrimes(30), 'sumOfPrimes(30) should equal 129');​ console.log('PASSED: ' + '`sumOfPrimes(30)` should equal `129`');} catch (err) { console.log(err);}​try { assert.deepEqual(381, sumOfPrimes(55), 'sumOfPrimes(55) should equal 381');​OUTPUT
:001 > Cmd/Ctrl-Enter to run, Cmd/Ctrl-/ to comment
We'll now take you through what you need to know.
How do I use this guide?


