js随机生成[n,m)的数字(不包括m)

Math.random();//随机生成0到1的数字

Math.floor();//取小整

Math.floor(Math.random()*(最大值 - 最小值) + 最小值)

生成2到8的数:Math.floor(Math.random()*(8 - 2) + 2)

posted @ 2018-08-02 22:20  雨筠  阅读(189)  评论(0编辑  收藏  举报