Sum All Primes , can someone explain what is happening

Tell us what’s happening:
Describe your issue in detail here.

``````  **Your code so far**
``````
``````
function sumPrimes(num) {
let newnum = []
for(let i=2; i<num; i++){
if(num%i===0){
newnum.push(i)
}
}
return newnum;
}

console.log(sumPrimes(10));
console.log(sumPrimes(6))
``````

Challenge: Sum All Primes

???

Hello there.

Do you have a question?

If so, please edit your post to include it in the Tell us what’s happening section.

Learning to describe problems is an important part of learning how to code.

Also, the more information you give us, the more likely we are to be able to help.

This code is finding numbers that divide into num. That is not the same thing as a prime number.

I invite you to think about what makes a prime number prime, and what you are pushing in instead. Also think about what kind of output they want, and what output you are outputting instead.

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.