China Naming Network - Almanac query - Who can write lottery code in javascript? You can't draw the same symbol repeatedly. One is ten signs.
Who can write lottery code in javascript? You can't draw the same symbol repeatedly. One is ten signs.
var arr = [ 1,2,3,4,5,6,7,8,9, 10]; //Ten labels, you can put any data.
Function getArr(arr){
var key = math . round(math . random()*(arr . length- 1));
Return arr.splice (key,1); //Every time you draw one, you really take it out of the array. If there is one symbol missing from the array, it won't be repeated.
}
alert(getArr(arr)[0]);
alert(getArr(arr)[0]);
alert(getArr(arr)[0]);