Created
June 10, 2014 18:19
-
-
Save AugustMiller/5e2b0384eb5701df05fd to your computer and use it in GitHub Desktop.
Get a random element from an array
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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