获取范围内的随机整数

189 阅读1分钟

获取范围内的随机整数

var x = 1
var y = 10
var stochastic= parseInt(Math.random() * (y - x + 1) + x); //1-10之间的随机整数(包含x和y)