**Tell us what’s happening:**

So I passed this challenge , I vaguely remember having a similar challenge in a java or c++ class about 2 years ago and breezed right through it but I know every language is different this took me awhile in Javascript.

I was unit testing the code by populating an array to see what my if statement was capturing and all the sudden it worked… but the array and its initialized variable has nothing to do with the accumulator variable.

The confusing part is that when I take the array variable out all the sudden it doesn’t work anymore but, from what I can see it serves no readily apparent purpose… any help would be appreciated…

**Your code so far**

```
/* Intermediate Algo Challenge
*Sum All Primes
*Sum all the prime numbers up to and including the provided number.
*
*A prime number is defined as a number greater than one and having only two divisors, one and *itself. For example, 2 is a prime number because it's only divisible by one and two.
*
*The provided number may not be a prime.
*/
/* PSEUDOCODE
1. Pass argument num into funciton sumPrimes.
2. Declare and initialize variable currentPrime assign a value 1.
3. Declare a and initialize variable sumOfPrimes assign a value 0.
4. Start a for loop where i=0 and incraments by 1 that runs until <= argument sqrt num.
5. In the loop check if a number is prime if so add to sumOfPrimes.
6. Return sumOfPrimes when loop is complete.
***&. added another function for checking Prime not sure why I need array to pass challenge
*/
function sumPrimes(num) {
var currentNum = 2;
var sumOfPrimes = 0;
var primeArray = []; //WHYY?
function isPrime(numTest) {
for (x = 2; x < numTest; x++) {
if (numTest % x === 0) {
return false;
}
}
return true;
}
for (i= 2; i <= num; i++) {
//console.log(i);
if (isPrime(i) == true) {
primeArray.push(i);//WHYY??? Doesn't appear to do anything the accumulator below seems to do the job
sumOfPrimes += i;
}
// console.log(sumOfPrimes);
}
console.log(primeArray);
console.log(sumOfPrimes);
return sumOfPrimes;
}
sumPrimes(10);
```

**Your browser information:**

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

.

**Link to the challenge:**

https://www.freecodecamp.org/challenges/sum-all-primes