Last active
December 26, 2015 18:19
-
-
Save HAKASHUN/7194020 to your computer and use it in GitHub Desktop.
Javascriptで配列をランダムにシャッフルする関数
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var shuffleArray = function(arr) { | |
for(var i = arr.length - 1; i >= 0; i--) { | |
var random = Math.floor(i * Math.random()); | |
var tmp = arr[i]; | |
arr[i] = arr[random]; | |
arr[random] = tmp; | |
} | |
return arr; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment