Nth Prime in JavaScript