1. // Math.random()
    2. // 默认情况下,生成的随机数是 0,1,包括0,不包括1
    3. // 生成1-10
    4. Math.floor(Math.random() * 10 + 1)
    5. // 生成 a-b 之间的数
    6. Math.floor(Math.random() * (b - a) + a)
    1. function random() {
    2. let arr = [];
    3. while (arr.length < 10) {
    4. arr.push(Math.floor(Math.random() * (100-10) + 10))
    5. }
    6. return arr.sort()
    7. }
    8. console.log(random());