/ * * * Produce a specified range which does not duplicate the random number * a parameters: minimum int * two parameters: the maximum value of int * three parameters: the number of random int * Return Value: Array result the Array * * / function getRandNumForRange (Least , max, NUM) { // check the legality by value iF (NUM> max - Least) return to false ; // produce a specified range of values all var numlist = [], numRandList = [], RANDID; for ( var I = least; i <max; i ++) NumList.push (I); // generating a record number for ( var I = 0 ; I <NUM; I ++ ) { RANDID = Math.floor (Math.random () * numList.length); // random array of a ID numRandList.push (numlist [RANDID]); // Get the value numList.splice (RANDID, . 1 ); // delete the next run again preventing members } return numRandList; } / * * * produce a specified array of non-repeating random number * a parameter: extracting the array array * two parameters: the number of random int * Return Value: Array result the Array * * / function getRandNumForArray (numarray, NUM) { // check if valid transmission value IF (NUM> numArray.length) return to false ; // generates a recording frequency var numRandList = [], RANDID; for ( var I = 0 ; I <NUM; I ++ ) { RANDID = Math.floor (Math.random () * numArray.length); // random array of a ID numRandList.push (numarray [RANDID]); // Get the value numArray.splice (randId, 1 );// delete this prevents members of the next generation again } return numRandList; }