Don't know why my sum all primes doesn't work, any ideas? thanks in advance

i thought second loop was problem, which tells how many divisor number has, and if it has two divisor it means its prime, but i checked that loop alone and it works, so now dont’t know why whole code doesn’t work, when i run it it returns 0.

function sumPrimes(num) {
  var sum = 0;
  var counter = 0;
  for(var i = num; i >= 1; i-- ){
    for(var j = i; j >= 1; j--){
      if(i%j == 0){
        counter++;
      }
    }
    if(counter == 2){
      sum += i;
      counter = 0;
    }
  }
  return sum;
}

console.log(sumPrimes(10));

It looks like you only reset your counter some of the time.

Your code should work if you fix that, though it might take too long to run and thus fail the tests.

thanks, it’s working now