I have a question, everytime I run my code I get 9 as an output which isn’t a prime number. I 've processed the original way from the mosh video, but this seems to output a non-prime number even after checking my code with the example.
Any assistance? I’d appreciate it!
showPrimes (10);
function showPrimes(limit){
for (let number = 2; number <= limit; number++){
if (isPrime(number)) console.log(number);
// 2 - current (i)
}
}
function isPrime(number){
for (let factor = 2; factor < number; factor++){
if (number % factor === 0)return false;
return true;
}
}