Skip to content

Instantly share code, notes, and snippets.



Created Jan 30, 2018
What would you like to do?
Random Array Picker
// Feed it an array and it will return you one entry from the array
function rand(array) {
return array[Math.floor(Math.random() * array.length)];
// Example
var sausages = [
"Pork and Apple"
let randomSausage = rand(sausages); // would return a sausage!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.