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


#1

Hi boy, there is my code which can through all the test case on our local PC.
but that unable to through the sumPrimes(977) test case on freecodecamp.
I need your help ASAP , thanks in advance !

function sumPrimes(num) {
  var primes = [];
  for (let i = 2; i <= num; i++) {
    var flag = true;
    for (let j = 2; j < i; j++) {
      if (i % j === 0) {
        flag = false;
      }
    }
    if (flag) primes.push(i);
  }
  return primes.reduce(function(total, item) {
    return total + item;
  });
}