美文网首页
获取随机数Math.random()

获取随机数Math.random()

作者: Allan要做活神仙 | 来源:发表于2017-04-25 13:18 被阅读40次

获取0~7之间的随机数

Math.floor(Math.random()*7)
Math.floor()          // 向下取整
Math.random()     // 获取0~1之间随机小数
Math.random()*7  // 获取0~7之间随机数

相关文章

网友评论

      本文标题:获取随机数Math.random()

      本文链接:https://www.haomeiwen.com/subject/zcdvzttx.html