//Generate random numbers from minimum min to maximum max function random(min,max){ if(min > max){ var ls = min; min = max; max = ls; } return Math. floor(Math. random() * (max-min+1) ) + min; }
Recommended tutorial: js introductory tutorial
The above is the detailed content of js to generate random numbers within a certain range. For more, please pay attention to other related articles on 1024programmer.com!