Sum All Primes Challenge: Right Values, does not pass the test

Tell us what’s happening:

Using another program, I ran the code, and it appears to return the right values (10 returns 17, 977 returns 73156) but the FCC tests say that sumPrimes(977) does not return the right value.

Any help appreciated

Your code so far

function sumPrimes(num) {
  let sum=0;
  let index =2;
    let isPrime=true;
    for(let i=2;i<index;i++)
      if(index % i ==0)
  return sum;


Your browser information:

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

Link to the challenge:

your code passes for me (I’m on chrome) , perhaps this is a browser issue ?

Your algorithm will be too slow, so the tests will be timing out. At the minute you’re doing a lot of unnecessary calculation (for starters, you’re checking even numbers). You’re going through every number multiple times, and that’ll work for small numbers, but as they get bigger the number of calculations your code needs to do just explodes.

It will work locally because your system isn’t designed to time out after a few milliseconds.