Intermediate Algorithm Scripting: Sum All Primes
I´m looking for an advice in what more should I implement to pass the last test (sumPrimes(977))
While the first two tests are passed, Last test with my code gives different sum of primes than the one FCC is asking. The problem is I have followed it´s tutorial about finding the primes (https://en.wikipedia.org/wiki/Sieve_of_Eratosthenes)upto the number 30 and the code delivers the same as the wikipedia´s example.
`function sumPrimes(num) {
var arrayNum = [];
var counter = 0
for (var i = 0; i < num; i++){
counter ++
arrayNum.push(counter)
}
arrayNum = arrayNum.slice(1,)
for (var i = 0; i < arrayNum.length; i++){
if (arrayNum[i] % 2 == 0){
if (arrayNum[i] === 2){1==1}
else {delete arrayNum[i]}
}
}
for (var i = 0; i < arrayNum.length; i++){
if (arrayNum[i] % 3 == 0){
if (arrayNum[i] === 3){1==1}
else {delete arrayNum[i]}
}
}
for (var i = 0; i < arrayNum.length; i++){
if (arrayNum[i] % 5 == 0){
if (arrayNum[i] === 5){1==1}
else {delete arrayNum[i]}
}
}
arrayNum = arrayNum.filter(x => Number.isInteger(x))
var sum= arrayNum.reduce((x,y) => {return x + y})
return sum
}
sumPrimes(977);`