首先我们要写一个方法好随时调用
function random(a,b) {
// 先要一个最大值和最小值
let min = Math.min(a,b)
let max = Math.max(a,b)
let res = Math.floor(Math.random()*( max - min + 1 )) + min
return res
}
console.log(random(10,20))