Created
May 4, 2019 23:32
-
-
Save nbogie/05332f6c8834f6b57a08d8ea1edd911b to your computer and use it in GitHub Desktop.
a function which, when given an array of elements, will return one element picked at random from that array.
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 pickRandom(arr) { | |
let ix = Math.floor(Math.random() * arr.length); | |
return arr[ix]; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment