Hello!
When cheking, the programm writes that “should return a number”.
I know, it is the return value of function, but I don’t understand what’s wrong.
function sumPrices (num){
var result= [];
var sum = 1;
nextPrime:
for(var a = 2; a <= num; a++) {
for (var b = 2; b < a; b++){
if (a % b == 0) {continue nextPrime;
}
}
result.push(a);
}
sum = result.reduce(function (a, b) {
return a+b;
});
return num = Number(sum);
}
sumPrices(10);
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.193 Safari/537.36
.
Challenge: Sum All Primes
Link to the challenge: