Skip to content

Instantly share code, notes, and snippets.

@jswhisperer
Created January 4, 2014 18:14
Show Gist options
  • Save jswhisperer/8258447 to your computer and use it in GitHub Desktop.
Save jswhisperer/8258447 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