Javascript: find first n prime numbers
- by bard
function primeNumbers() {
array = [];
for (var i = 2; array.length < 100; i++) {
for (var count = 2; count < i; count++) {
var divisorFound = false;
if (i % count === 0) {
divisorFound = true;
break;
}
}
if (divisorFound == false) {array.push[i];}
}
return array;
}
When I run this code, it seems to get stuck in an infinite loop and doesn't return anything... why?