Home > front end > Array to join member, must reach to the condition of problem
Array to join member, must reach to the condition of problem
Time:02-05
Ask you a favor, thought for a long time all can't think of, here thank you for your first
CodePudding user response:
Requests for the final number of elements in the array without circulation 50 times no problem, have the requirement is to determine the length of the array
Var arr=[]; for(var i=0; i<50; I++) { Var n=parseInt (1 + Math. The random () * 60); If (arr. Length==0 | | math.h abs (n - arr (arr. Length - 1)) & gt; { =3)Arr. Push (n); } } The console. The log (arr);