Here you can find the source of exchange(i1,i2)
Array.prototype.exchange = function(i1,i2) { var tmp = this[i1]; this[i1] = this[i2];/*from w ww . j a v a2 s . c o m*/ this[i2] = tmp; };
Array.prototype.exchange = function(i1,i2) { var tmp = this[i1]; this[i1] = this[i2]; this[i2] = tmp; }; var randomizeInPlace = function(A) { for (var i = 1, n = A.length; i < n; i++){ A.exchange(i,getRandomIntInclusive(0,i)); return A; }; module.exports = randomizeInPlace;