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
console.log(sumPrimes(977)); // should return 73156. But it returns 72179