But after a little hard work, I finally figured it out, and the problem was naturally solved.
Then I wrote a formula, which should make this usage disappear. Formula:
1 . Starting from 1 to any value
linenum
parseInt(Math.random()*upper limit 1);
2. Starting from any value to any value
linenum
parseInt(Math.random ()*(upper limit - lower limit 1) lower limit);
The above formula uses parseInt(), so you need to add 1; if you use Math.ceil(), you don’t need to add 1. I am used to writing like this...
Directory:
1. Demonstration 1 (directly perform the operation of generating random numbers)
2. Demonstration 2 (write as a function to perform the operation of generating random numbers)
1. Demonstration 1 (directly perform the operation of generating random numbers) )
linenum
1-10:
11-20:
1-100:
51-100:
2. Demonstration 2 (written as a function to generate random numbers)
linenum
1-10:
11-20:
1-100:
51-100: