Skip to content

Instantly share code, notes, and snippets.

@TorvaldsDB
Created November 10, 2019 07:07
Show Gist options
  • Save TorvaldsDB/882b1557a1f4bcd8c80d876053e8fac3 to your computer and use it in GitHub Desktop.
Save TorvaldsDB/882b1557a1f4bcd8c80d876053e8fac3 to your computer and use it in GitHub Desktop.
JS how to return a sample of an array?
arr = [1, 2, 3, 4 , 5]
arr[Math.floor(Math.random() * arr.length)]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment