function sumPrimes(num) {
// arg smaller than 2 is unnecessary..
if(num<2) return 'invalid input';
// create a full array..
var arr=[];
for (let iterator=2; iterator<=num; iterator++){
arr.push(iterator);
}
// use filter and reduce to return the sum of prime numbers
return arr.filter(isPrime).reduce((first,second) => first+second);
}
// function to judge an arg, to be called within the function above
function isPrime(a){
for(var i=2;i<a;i++){
if(a%i==0) return false;
}
if(i==a) return true;
}
sumPrimes(10);