Node.js examples for Array:Shuffle
Shuffle array
Array.prototype.shuffle = function() { var arr = this, elm, inc, length = arr.length; while (length) { inc = Math.floor(Math.random() * length--); elm = arr[length];//from w w w .j a v a2 s . com arr[length] = arr[inc]; arr[inc] = elm; } return arr; };