```
function sumPrimes(num) {
var primeArr = [];
// array to store prime numbers
var numArr = [];
// array to store all numbers up to prime number
for (var i = 2; i <= num; ++i) {
// SO Sieve of Eratosthenes implementation
if (!numArr[i]) {
// i has not been marked -- it is prime
primeArr.push(i);
for (var x = i << 1; x <= num; x += i) {
numArr[x] = true;
}
}
}
var primeSum = primeArr.reduce(function(total,currentVal) {
// sum all prime numbers together & store result
return total + currentVal;
});
return primeSum;
// return result
}
sumPrimes(10);
```

i looked at the forum help for this as i’ve been struggling with it for some time. i’ll admit math isn’t really my strong suit.

Anyway, i’ll be 100% honest, i implemented someones elses alg for finding primes.

I know the general rule is “not to copy others code”, but the forum help article by Rafase282 seems to suggest that it’s ok in this instance?

Can anyone confirm that this is definitely the case?