Unique Random Numbers II

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 this :
pickNums(4)

Could be useful :-)

Here's an example :

Reload the page to see a set of another unique random numbers.

This script is a slightly modified version of Unique Random Numbers. In this script it becomes easier to implement more than one instances of "Picking Unique Random Numbers".

See the implementation of this script in Unique Random Sets.
© 2002 Premshree Pillai.