```
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?