HuyPV
Wednesday, April 11, 2012
shuffle = function(arr){
for(var j, x, i = arr.length; i; j = parseInt(Math.random() * i), x = arr[--i], arr[i] = arr[j], arr[j] = x);
return arr;
};
alert([0, 1, 2, 3, 4, 5, 6, 7, 8, 9]);
Title:
javascript - shuffle array
Description:
shuffle = function(arr){ for(var j, x, i = arr.length; i; j = parseInt(Math.random() * i), x = arr[--i], arr[i] = arr[j], arr[j] = x); ret...
...
Rating:
4