Tell us what’s happening:
What’s wrong with my code?
Your code so far
function sumPrimes(num) {
let arr = [2, 3];
for (var i = 2; i <= num; i++) {
if (i % 2 !==0 && i % 3 !==0) {
arr.push(i);
}
}
console.log(arr);
let sum = arr.reduce(function(total, item) {
return total += item;
})
return sum;
}
sumPrimes(10);
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:62.0) Gecko/20100101 Firefox/62.0
.
Link to the challenge:
https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/intermediate-algorithm-scripting/sum-all-primes