Skip to content

Instantly share code, notes, and snippets.

@Kolenov
Created February 24, 2017 20:52
Show Gist options
  • Save Kolenov/78450860ba7c9dcc7542de30aaa16cba to your computer and use it in GitHub Desktop.
Save Kolenov/78450860ba7c9dcc7542de30aaa16cba to your computer and use it in GitHub Desktop.
Get a random item from an array
var items = [12, 548 , 'a' , 2 , 5478 , 'foo' , 8852, , 'Doe' , 2145 , 119];
var randomItem = 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