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));