JS---获取30~40之间的一个随机数

267 阅读1分钟

获取30~40之间的一个随机数

     function rnd(max, min = 0) {
         return Math.round(Math.random() * (max - min)) + min
      }

     console.log(rnd(40, 30));
     console.log(rnd(40));