Created
October 3, 2016 06:29
-
-
Save geminorum/afcbea170d9b2cc53959138e0c3a0e1f to your computer and use it in GitHub Desktop.
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
/** | |
* Shuffles array in place. | |
* @param {Array} a items The array containing the items. | |
*/ | |
function shuffle(a) { | |
var j, x, i; | |
for (i = a.length; i; i--) { | |
j = Math.floor(Math.random() * i); | |
x = a[i - 1]; | |
a[i - 1] = a[j]; | |
a[j] = x; | |
} | |
} | |
var myArray = ['1','2','3','4','5','6','7','8','9']; | |
shuffle(myArray); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment