Skip to content

Instantly share code, notes, and snippets.

@Angelfire
Last active August 25, 2022 20:14
Show Gist options
  • Save Angelfire/1432fc08704b890920e6d15a0ad6563b to your computer and use it in GitHub Desktop.
Save Angelfire/1432fc08704b890920e6d15a0ad6563b to your computer and use it in GitHub Desktop.
Get multiple random items from array
const getMultipleRandomItems = (arr, num) => {
const shuffled = [...arr].sort(() => 0.5 - Math.random())
return shuffled.slice(0, num)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment