Skip to content

Instantly share code, notes, and snippets.

@AugustMiller
Created June 10, 2014 18:19
Show Gist options
  • Save AugustMiller/5e2b0384eb5701df05fd to your computer and use it in GitHub Desktop.
Save AugustMiller/5e2b0384eb5701df05fd to your computer and use it in GitHub Desktop.
Get a random element from an array
Array.prototype.pick = function ( ) {
return this[ Math.floor( Math.random() * this.length ) ];
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment