Skip to content

Instantly share code, notes, and snippets.

@ankitnetwork18
Created January 11, 2013 07:17
Show Gist options
  • Save ankitnetwork18/4508654 to your computer and use it in GitHub Desktop.
Save ankitnetwork18/4508654 to your computer and use it in GitHub Desktop.
javascript: get random values from array
var cities = ['delhi', 'mumbai', 'pune'];
function getRandomCity() {
return cities[Math.floor(Math.random() * cities.length)];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment