I’m not sure what is wrong with my code. Am I on the right track?
Sorry I’m still a novice with JS.
function sumPrimes(num) {
var sum = 0;
var currentVal = 2;
while (currentVal <= num) {
for (var i = 2; i < currentVal; i++) {
if (currentVal % i == 0) {
continue;
} else {
sum += currentVal;
}
}
currentVal++;
}
return sum;
}
console.log(sumPrimes(10));
**Your browser information:**
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/88.0.4324.190 Safari/537.36
.
Challenge: Sum All Primes
Link to the challenge: