Skip to content

Instantly share code, notes, and snippets.

@bjrnqprs
Created November 15, 2013 10:15
Show Gist options
  • Save bjrnqprs/7482144 to your computer and use it in GitHub Desktop.
Save bjrnqprs/7482144 to your computer and use it in GitHub Desktop.
Return a random value from the given non-associative array
/**
* Return a random value from the given non-associative array
*
* @param array
* @returns {*}
*/
function getRandomArrayValue(array) {
return array[Math.floor(Math.random() * array.length)];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment