Skip to content

Instantly share code, notes, and snippets.

@hmmhmmhm
Created September 13, 2021 08:01
Show Gist options
  • Select an option

  • Save hmmhmmhm/9dc7dd5a11babb55d5aa32ed2c9bd412 to your computer and use it in GitHub Desktop.

Select an option

Save hmmhmmhm/9dc7dd5a11babb55d5aa32ed2c9bd412 to your computer and use it in GitHub Desktop.
A method of generating random values that are not duplicated...
// if you want better performance, use fpe
// https://gist.github.com/hmmhmmhm/89e200e3501b4d155901baee3cae0f74
const rand = (max) => ~~(Math.random() * max)
const items = []
while(items.length === 100){
const item = rand(100)
if(!items.includes(item))
items.push(item)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment