How to define numbers properly in JS

Tell us what’s happening:
I am trying to troubleshoot why the first two test pass but the second two do not. I see that the last 2 cases output the same number. Do I need to define my total variable differently to get the correct answer? I was having trouble finding resources that go in depth on how numbers are defined and what the ranges are for var and let.

Your code so far

function primeSummation(n) {
// Good luck!
//base case 
let vecOfPrimes = [2]
let total = 0

//helper function that will test is the number we are looking at prime?  
function isPrime(arr, number){

// .every is used to make sure a condition is satisfied for EVERY element in an
var result = arr.every(function (e) {
  return number % e 

//if it is true then push the element into the array 
if (result == true){


//use recursion to run the helper function repeatedly to get the nth
//prime number up to the 10001st prime number
for(let i = 3; vecOfPrimes.length < 10001; i++){
isPrime(vecOfPrimes, i)


function isSmallEnough(value) {
return value < n;

var filtered = vecOfPrimes.filter(isSmallEnough);

for(let i =0; i < filtered.length ; i ++){
total += filtered[i]

return total;


Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/77.0.3865.90 Safari/537.36.

Challenge: Problem 10: Summation of primes

Link to the challenge: