Skip to content

Instantly share code, notes, and snippets.

@nikolas
Created December 7, 2018 19:41
Show Gist options
  • Save nikolas/96586a0b56f53eabfd6fe4ed59fecb98 to your computer and use it in GitHub Desktop.
Save nikolas/96586a0b56f53eabfd6fe4ed59fecb98 to your computer and use it in GitHub Desktop.
const shuffleArray = function(array) {
const a = array.slice();
for (let i = a.length - 1; i > 0; i--) {
const j = Math.floor(Math.random() * (i + 1));
[a[i], a[j]] = [a[j], a[i]];
}
return a;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment