Sum All Primes[Got the correct result, but wouldn't pass the test]

Tell us what’s happening:
I got the correct result in my console output, but when I tried to run the test in freeCodeCamp test challenge editor, it wouldn’t pass the test for sumPrimes(977);
Is this a bug in their test, or is my code wrong?

Your code so far


function sumPrimes(num) {
  let sum=2;
      const isPrime=n=>{
          let flag=0;
        for(let i=2;i<n;i++){
            if(n%i===0)
            flag++;
        }
        return flag===0?true:false;
      };
      for(let i=3;i<=num;i++){
          if(isPrime(i))
          sum+=i;
      }
      return sum;
}

sumPrimes(977);

Your browser information:

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

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

FCC uses infinite loop protection to prevent campers from having to deal with their browsers crashing when they write an infinite loop or infinite recursion. This is timer-based, so it may just be that your solution is slow enough that it triggers the loop protection.

Ahh I see. I had to admit that my code is inefficient, but so does the solution(basic/beginners) they provided in the hint section. Thanks anway.