Yeah my solution definitely could be better, I was just really happy to get through it haha
I thought my solution was poor, but honestly none of the other solutions here are easier to understand freeCodeCamp Challenge Guide: Sum All Primes
let myArr = [];
let count = 0;
for (let i = 2; i <= num; i++) { //all numbers 2 thru NUM
//console.log("outer loop, index is", i);
myArr.push(i);
for (let n = 2; n <= num; n++) { //all numbers 2-NUM
//console.log(i%n===0, "n is ", n);
if (i % n === 0 && i > n) {
console.log(i, ", there is a remainder! it is divisble!");
count = 1;
if (myArr.indexOf(i) > 0 && count > 0) {
count = 0;
myArr.pop();
//console.log(myArr);
}
} //if
}; //inner loop
}; //outer loop
let addPrimes = myArr.reduce((a, b) => a + b);
return addPrimes;
return num;