Sum All Primes new

I ask for your help.
Something I was stuck on the last test sumPrimes(977) should return 73156

function sumPrimes(num) {

  let total = 0;

  for (let p = 2; p < num; p++) {

          let folded = false;

      for (let divider = 2; divider < p; divider++) {

          let x = p / divider;

          if ((x ^ 0) === x) {
            folded = true;          
            if (folded == false) {
              total += p;
        console.log("Primes " + p);



  return total;


Your browser information:

User Agent is: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/64.0.3282.140 Safari/537.36.

Link to the challenge:

It may be you are triggering the infine loop protection, and you need to refactor your code so that your loops need less time to execute, both your loops increment by one at a time and that may be a bit much to reach 977

1 Like

Thanks for the advice. I’ll try to do it