Created
February 28, 2018 11:02
-
-
Save vldvel/48075ba6380eda34a943c8a9fafd4121 to your computer and use it in GitHub Desktop.
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
| function * randomFrom(...arr) { | |
| while (true) | |
| yield arr[Math.floor(Math.random() * arr.length)]; | |
| } | |
| const getRandom = randomFrom(1, 2, 5, 9, 4); | |
| getRandom.next().value; // returns random value |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment