Prime Number generator in JavaScript