Skip to content

Instantly share code, notes, and snippets.

@tim545
Last active December 11, 2015 05:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tim545/4cddce0c65e86aca5b4a to your computer and use it in GitHub Desktop.
Save tim545/4cddce0c65e86aca5b4a to your computer and use it in GitHub Desktop.
Add a method to the Array prototype to return a random array item
// Adds a method to the Array prototype to return a random array item
Array.prototype.random = 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