Created
September 13, 2021 08:01
-
-
Save hmmhmmhm/9dc7dd5a11babb55d5aa32ed2c9bd412 to your computer and use it in GitHub Desktop.
A method of generating random values that are not duplicated...
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // 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