Array.prototype.map

arr.map(function (elem, i) { return nthPrime(elem); }); //returns a new array with nth prime numbers as elements