Home > front end >  Random lottery the double chromosphere JavaScript implementation
Random lottery the double chromosphere JavaScript implementation

Time:05-20

Small white learning wed development

Practice randomly selected number of 7 digits, the double chromosphere, 6 red balls, basketball 1
If write wrong, welcome to diss, HHHH, for the first time to write


Var a=[' 1 ', '2', '3', '4', '5', '6', '7', '8', '9', '10', '11', '12' and '13', 14 ' ', '15', '16', '17', '18', 'the', '20', '21', '22', '23', '24', '25', '26', '27', 'and', '29', '30', 'and', '32', '33'].

Var b=[' 1 ', '2', '3', '4', '5', '6', '7', '8', '9', '10', '11', '12' and '13', '14' and '15', '16']

Var red1=[];
Var blue1=[];
for (var i=0; I<6; I++) {
Var num=Math. Floor (Math. The random () * a. ength);
Red1. Push (a (num));
A.s plice (num, 1);
Red1. Sort (function (n1, and n2) {
Return n1, n2;
})
}
The console. The log (' red balls: + red1);

Var num2=Math. Floor (Math. The random () * b.l ength);//to draw random subscript
Blue1. Push (b [num2]);

The console. The log (' basketball: '+ blue1);

CodePudding user response:

Should have no problem in logic, red1 if you want to be from small to large, the sort of don't need to write in the for take after row again,
You red ball random words, however, seen from the results, it can give it a random sort once, and then take six before, also can, blue ball since there is only one, need not array, is equal to a number directly

CodePudding user response:

Behind the sort don't write in the for the return will not be carried out

CodePudding user response:

_ xiao _114 reference 2 floor response:
sort don't write in the for return back is not carried out

What does not perform the return behind? Red1 sort of random red ball didn't any relationship with you...
  • Related