Created
September 12, 2018 18:54
-
-
Save gate5th/825e1d9d025afa14db171ab8258ae068 to your computer and use it in GitHub Desktop.
oldschoolshuffle
This file contains 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
function shuffleArray(input) { | |
for (let i = input.length-1; i >=0; i--) { | |
const randomIndex = Math.floor(Math.random()*(i+1)); | |
const itemAtIndex = input[randomIndex]; | |
input[randomIndex] = input[i]; | |
input[i] = itemAtIndex; | |
} | |
return input; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment