**Tell us what’s happening:**

I wrote a function to find out whether a number is prime or not and that seems to work fine.

But, it doesn’t work while i try to add the primes.

I don’t understand why this doesn’t work?

`if(isPrime(j)){`

newArr.push(j);

}

**Your code so far**

```
function isPrime(num1){
var remainder = [];
var squareroot = Math.floor(Math.sqrt(num1))
for(let i=2;i<squareroot;i++){
remainder.push(num1%i);
}
if(remainder.includes(0)){
return false;
}
return true;
}
function sumPrimes(num) {
var newArr =[]
for(let j=1;j<num;j++){
if(isPrime(j)){
newArr.push(j);
}
}
return newArr.reduce(((a,b) => a+b),0);
}
sumPrimes(10);
```

**Your browser information:**

User Agent is: `Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/68.0.3440.106 Safari/537.36`

.

**Link to the challenge:**

https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/intermediate-algorithm-scripting/sum-all-primes