if the input is 10 the code works correctly but on the higher numbers like 977 something goes wrong.

```
function sumPrimes(num) {
let result = 2
for(let i = 2; i <= num; i++){
for(let j = 2; j < i; j++){
if(i % j !== 0){
if(j == i - 1){
result += i
}
} else if(i % j == 0){
j = 2
i++
}
if( i == num){
break
}
}
}
return result;
}
console.log(sumPrimes(977));
```

**Your browser information:**

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

**Challenge:** Intermediate Algorithm Scripting - Sum All Primes

**Link to the challenge:**