Skip to content

Instantly share code, notes, and snippets.

@lgrachov
Created September 1, 2024 21:10
Show Gist options
  • Save lgrachov/5cab0cd2e5edf91e46dd85c94e1ec719 to your computer and use it in GitHub Desktop.
Save lgrachov/5cab0cd2e5edf91e46dd85c94e1ec719 to your computer and use it in GitHub Desktop.
Get random item from list in JavaScript
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