Forum Moderators: open

Message Too Old, No Replies

Unique Random Numbers

         

bateman_ap

12:23 pm on Sep 29, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Hi, I am trying to create 4 unique random numbers between 1 and 20. Using the code gives me 4 numbers but not always unique. Looking around for some tutorials drew a blank.

choice = Math.round(Math.random()*20);
choice2 = Math.round(Math.random()*20);
choice3 = Math.round(Math.random()*20);
choice4 = Math.round(Math.random()*20);

Many thanks