Sum All Primes (I can't find my mistakes)

Tell us what’s happening:
I wrote this code to solve but it seems to have something wrong

Your code so far

function sumPrimes(num) {
    numArray = [];
    var sum = 0;

    function isPrime(num) {
        for (var i = 2; i < num; i++) {
            if (num % i === 0) {
                return false;
            }
        }
        return num;
    }

    for (var i = 2; i < num; i++) {
        if (isPrime(i)) {
            numArray.push(i);
        }
    }


    for (var j = 0; j < numArray.length; j++) {
        sum += numArray[j];
    }
    return sum;
}


console.log(sumPrimes(10)); // should return 17 and it does :smile:
console.log(sumPrimes(977)); // should return 73156. But it returns 72179 :sleepy:

The instructions state “Sum all the prime numbers up to and including the provided number”. Your code only sums all the prime number up to and excluding the provided number. You just need to change a < to a <=

I’m having trouble understanding why sumPrimes(10) should return 17. Shouldn’t it return 27 instead? Because the array of primes is: [ 2, 3, 5, 7, 10 ]. Am I missing something here?

oh God of course! sorry about that dumb question!