求范围内的随机数
function rangeRandom(a, b) {
var max = Math.max(a, b)
var min = Math.min(a, b)
var res = Math.floor(Math.random() * (max - min + 1) + min)
return res
}
var n = 30
var m = 50
var obj = {}
for (var i = 0; i < 100000; i++) {
var res = rangeRandom(10, 20)
if (obj[res]) {
obj[res]++
}
else {
obj[res] = 1
}
}
console.log(obj)