array of random numbers [duplicate]

2019-01-20 11:54发布

问题:

Possible Duplicates:
Random number generator without dupes in Javascript?
Generate 8 unique random numbers between 1 and 100

HI, I want to create an array of random numbers which should have unique values.i want to do this using java script ,Can any one give me a solution...?

回答1:

Create an array of numbers:

var min = 0,
    max = 1000,
    i,
    arr = [];

for (i = min; i<max; i++)
{
    arr.push(i);
}

Then shuffle it.