Skip to content

Instantly share code, notes, and snippets.

@gate5th
Created September 12, 2018 18:54
Show Gist options
  • Save gate5th/825e1d9d025afa14db171ab8258ae068 to your computer and use it in GitHub Desktop.
Save gate5th/825e1d9d025afa14db171ab8258ae068 to your computer and use it in GitHub Desktop.
oldschoolshuffle
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