Last active
April 27, 2020 00:38
-
-
Save StuffbyYuki/24d915a1061b4a385b644ccbd7b5ffc0 to your computer and use it in GitHub Desktop.
JS - Get random element from the specified 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
//You specify an array of item in the argument | |
function random_item(items) { | |
return items[Math.floor(Math.random()*items.length)]; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment