js实现规定范围内的两位随机数

时间:2021-02-25 12:00:42   收藏:0   阅读:0
function getRandomIntInclusive(min, max) {
    min = Math.ceil(min);
    max = Math.floor(max);
    return Math.floor(Math.random() * (max - min + 1)) + min; //含最大值,含最小值 
  }
getRandomIntInclusive(50,99)//包含50和99

 

评论(0
© 2014 mamicode.com 版权所有 京ICP备13008772号-2  联系我们:gaon5@hotmail.com
迷上了代码!