Skip to content

Instantly share code, notes, and snippets.

@victornpb
Created October 8, 2019 03:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save victornpb/f6321bf507648e3bca19173fe27a2825 to your computer and use it in GitHub Desktop.
Save victornpb/f6321bf507648e3bca19173fe27a2825 to your computer and use it in GitHub Desktop.
function shuffle(arr) {
const a = arr.slice();
for (let i = a.length; i; i--) {
let j = Math.floor(Math.random() * i);
[a[i - 1], a[j]] = [a[j], a[i - 1]];
}
return a;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment