Created
September 1, 2024 21:10
-
-
Save lgrachov/5cab0cd2e5edf91e46dd85c94e1ec719 to your computer and use it in GitHub Desktop.
Get random item from list in JavaScript
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
const randomItemFromList = (list) => { | |
/* Simple helper function to get a random item from a list. */ | |
return list[Math.floor(Math.random() * list.length)]; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment