Skip to content

Instantly share code, notes, and snippets.

@akbarjondev
Created February 26, 2021 06:33
Show Gist options
  • Save akbarjondev/0c587482992957c5bfa3e5c48384978d to your computer and use it in GitHub Desktop.
Save akbarjondev/0c587482992957c5bfa3e5c48384978d to your computer and use it in GitHub Desktop.
How to shuffle Array in JavaScript
const shuffleArray = (arr) => {
const copyArr = [...arr]
return copyArr.sort(() => Math.random() - 0.5)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment