Maine,
<script>
function printPrime(limit) {
var result = [],
isPrime = false,
number = 1;
for (number; number < limit; number++) {
for (i = 2; i <= number; i++) {
if (number % i == 0 && number != i) {
isPrime = false;
break;
} else {
isPrime = true;
}
}
if (isPrime) {
result.push(number);
}
}
console.log(result);
}
printPrime(10);
</script>
https://ru.wikipedia.org/wiki/Простое_число