So I am doing the sum all primes algorithm, my question is, is it possible to add multiple tests in the filter method? and if so how?
function sumPrimes(num) {
let potentialPrime = [];
let i = num;
while (i > 1) {
potentialPrime.push(i);
i--;
}
console.log(potentialPrime)
const primeNumber = potentialPrime.filter((number) => {
return number / number && number / 1;
})
console.log(primeNumber)
}
sumPrimes(10);
What exactly are you hoping to do in this line? The filter method callback expects a return a truthy or falsy value. How will either side of the && happen?