Sum All Primes infinite loop

Sum All Primes infinite loop
0.0 0


Tell us what’s happening:
So, my second while loop is doing it’s job of removing all composite numbers, but I just don’t know how to make it stop. Any help would be appreciated!

Your code so far

function sumPrimes(num) {
  var arr = [];
  var digit1 = 1;
  while (digit1 < num){
  var index = 0;
  var digit2= arr[index];
  var digit3= arr[index];
  var del;
  while(Math.pow(digit2, digit2)<num){
    while (digit3 <= num){
         digit3 += digit2;
         del = arr.indexOf(digit3);
  return ;


Your browser information:

Your Browser User Agent is: Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/65.0.3325.181 Safari/537.36.

Link to the challenge:


Pay attention to where you’re using index in your code.

Also, isn’t it a little complicated your code? :slight_smile: