Skip to content

Instantly share code, notes, and snippets.

@lxneng
Created July 15, 2019 02:22
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 lxneng/e6bf1f0a598a02d0987bc25fd36ac94f to your computer and use it in GitHub Desktop.
Save lxneng/e6bf1f0a598a02d0987bc25fd36ac94f to your computer and use it in GitHub Desktop.
shuffe array
function shuffle(a) {
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