Posted By

1man on 11/12/07


Tagged

number random function


Versions (?)

Who likes this?

4 people have marked this snippet as a favorite

vali29
blackabee
jamesming
donesmart


Random Number


 / Published in: JavaScript
 

Very simple random number generator, generates a number that then runs a function that is inside an array. Used a version of this with UFO flash script to pull in a random flash object on a page.

  1. function runMe(){
  2. var test1 = function(){
  3. alert("Test 1 has been fired");
  4. }
  5. var test2 = function(){
  6. alert("Test 2 has been fired");
  7. }
  8. var myArray = [test1, test2]
  9. var randomNumber = Math.floor(Math.random()*2);
  10. myArray[randomNumber]();
  11. }

Report this snippet  

Comments

RSS Icon Subscribe to comments
Posted By: gfazioli on February 13, 2009

;P very good!

You need to login to post a comment.