Unique Random Numbers
Publisher
JavaScript to pick up a number of unique random elements from an array.
Product Details
This JavaScript picks up a number of unique random elements from an array. For example; if you have an array myArray consisting of 10 elements and want to pick 5 unique random elements. Suppose initially myArray[3] is picked randomly, then myArray[3] should not be picked again. If you want to pick 4 numbers, call the function like: pickNums(4).
Inout Shopping Cart - Multi Vendor EditionSponsored
posted byinoutscriptsinShopping Carts
PriceUSD 899.00
Views11776
Video Theme: Setup a website like YouTube today (New 2022) - Download Now!Sponsored
posted byshopperpressinSocial Networking
PriceUSD 99.00
Views3734
Inout RealEstate - Map Based Advanced Real Estate PortalSponsored
posted byinoutscriptsinReal Estate
PriceUSD 499.00
Views6249
Inout Blockchain AltExchanger (Crypto to crypto trading exchange platform script)Sponsored
posted byinoutscriptsinBlockchain & Cryptocurrency
PriceUSD 3,449.00
Views5063
User Reviews
Please rate the listing and tell the world know what do you think about the listing.
Very long winded code.
Reviewed byAnonymousonMon, 17th April 2006
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.