function isPrime(x) {
for (let i = 2; i < x; i++) {
if (x % i === 0) return false;
}
return x !== 1 && x !== 0;
}
Hi everyone,
I am wondering for x = 2, does it get passed into this function? Or, does it not get passed because the for loop specifies that i < x?
If x = 2 does get passed, I don’t see how it returns true as 2 % 2 === 0, so return false.
This is from the Sum All Primes challenge.
Thanks