关于javascript:js生成一定范围内的随机整数

9次阅读

共计 144 个字符,预计需要花费 1 分钟才能阅读完成。

Math.floor(Math.random()*(m-n+1)+n)
其中 m 为随机数的最大值,n 为随机数的最小值
如:
Math.floor(Math.random() * (20 – 10 + 1) + 10);
生成 1 -50 内的随机整数

转自:https://www.cnblogs.com/mmykd…

正文完
 0