loading
open in
main.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
function sumPrimes(num) {
 var a = [2,3,5,7];
for (var i = 2; i < num;i++){ 
if (i % 2 !== 0){
if( i % 3 !== 0){
if(i % 5 !== 0){
if(i % 7 !== 0){
  console.log(i);
  a.push(i);}}}}
}
   var total = a.reduce(function(sum, value) {
  return sum + value;
}, 0);
console.log(a);
  return total;
  
 
}

sumPrimes(977);
Native Browser JavaScript