 |
Hotscripts :: Listing Reviews |
|
|
 |
Reviews for Listing # 17104
Very long winded code., Apr 17, 2006
Reviewed By:
felgall
Review Of:
Unique Random Numbers in JavaScript :: Randomizing :: Combination
|
An extremely long way around way to do it when sorting the array into random order and then reading the resultant entries sequentially can be done in two lines of code.
myArray = new Array('1','2','3','4','5' ,'6');
// code to randomize array follows
function randOrd(){return (Math.round(Math.random() )-0.5); }
myArray.sort( randOrd );
// and from here you just read as many random selections you want from the front of the array.
|
|
 |
|
|