Sum All Primes please help

Sum All Primes please help
0.0 0

#1

Tell us what’s happening:
Please any help how to fix this! How to give me the right number when i check 977?

Your code so far

function sumPrimes(num) {
  var numb = [];
  var last = [2];
  
for(var i = 1; i< num; i++){
 
  numb.push(i);
 
}
  for(var x = 2; x< numb.length; x++){
      
     if(x%2 == 1){
       
       
       last.push(x);
    
  }
}
  return last;
}

sumPrimes(10);

Your browser information:

Your Browser User Agent is: Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/65.0.3325.181 Safari/537.36.

Link to the challenge:


#2

What you’re doing is putting the primes into an array and returning the array object.

What you need to do instead is add the prime numbers and return the total, in the form of a number (or variable with a number value).


#3

Yes i know, but when i sum 977 the return is not correct. i used .reduce() to sum the numbers. The problem here is the function doesn’t return the right numbers.