Tell us what’s happening:
Describe your issue in detail here.
Your code so far
I am not getting why is not passing the test.
function sumPrimes(num) {
function checkPrimes(number) {
for(let i = 2; i < number; i++) {
if(number % i === 0) {
return false
}
return true
}
}
let result = 0;
for(let j = 2; j <= num; j++) {
if(checkPrimes(j)) {
result += j
}
}
return result
}
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/115.0.0.0 Safari/537.36
Challenge: Intermediate Algorithm Scripting - Sum All Primes
Link to the challenge: