Sum All Primes-Need help

Sum All Primes-Need help
0

#1

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


#2

You didn’t understand the assignment. A prime number is a number that only for num%num or num%1 gives 0 and for all other numbers n between 1 and num gives num%n!=0, not a number that gives num%2 and num%3!=0