**Tell us what’s happening:**

I’m almost there! I spent quite some time trying to figure this out myself and it seems I’ve gotten really far. Currently, it looks like my code works for smaller numbers but I have no clue to what extent. When FCC tests the code with sumPrimes(977), it returns the wrong value. Any help is appreciated. Thank you in advance!

**Your code so far**

```
function sumPrimes(num) {
let res = 0;
let primes = [2, 3];
let prime = true;
//check each number that is less than or equal to argument
for( let i = 4; i <= num; i++ ){
prime = true;
//if number divisible by anything other than 1 or itself, it isn't prime. checking for remainders
for( let curr = 2; curr < i; curr++ ){
if( i % curr == 0 ){
//set prime to false if it isn't prime
prime = false;
}
}
//if, in the end, the number is still considered prime, push it to the array of prime numbers
if( prime == true ){
primes.push( i );
}
}
//Add everything within primes array and return
console.log( primes, primes.reduce( ( a, b ) => a + b) );
return primes.reduce( ( a, b ) => a + b );
}
sumPrimes(23);
```

**Your browser information:**

User Agent is: `Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:60.0) Gecko/20100101 Firefox/60.0`

.

**Link to the challenge:**

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