Skip to content

Instantly share code, notes, and snippets.

@charliemaffitt
Created April 23, 2009 18:27
Show Gist options
  • Save charliemaffitt/100664 to your computer and use it in GitHub Desktop.
Save charliemaffitt/100664 to your computer and use it in GitHub Desktop.
var rand = Math.floor(Math.random()*index); // generate the random number
var rand2 = Math.floor(Math.random()*index); // generate the second random number
if (rand == rand2) {
var rand2 = Math.floor(Math.random()*index); // generate another random number
}
if (rand == rand2) {
var rand2 = Math.floor(Math.random()*index); // generate another random number (this raises the chance of duplicate entries to 1/64)
}
if (rand == rand2) {
var rand2 = Math.floor(Math.random()*index); // generate another random number (this raises the chance of duplicate entries to 1/512)
}
if (rand == rand2) {
var rand2 = Math.floor(Math.random()*index); // generate another random number (this raises the chance of duplicate entries to 1/4096)
}
var quote = quote_array[rand]; // get the first quote from the array
var quote2 = quote_array[rand2]; // get the second quote from the array
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment