Created
September 10, 2015 22:25
-
-
Save cacheflow/bf6b8d4e96dab6e79847 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
Array.prototype.shuffle = function(array_elements) { | |
var i = array_elements.length, randomNum, randomNumIndex; | |
while(--i > 0) { | |
randomNum = Math.floor(Math.random() * (i + 1)); | |
randomNumIndex = array_elements[randomNum]; | |
array_elements[randomNum] = array_elements[i]; | |
array_elements[i] = randomNumIndex; | |
} | |
return array_elements; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment