获取5-10,参数可修改
<script>
// [min,max]
// function getRandom(min,max){
// return Math.floor(Math.random()*(max-min+1))+min;
// }
// (min,max)
// function getRandom(min,max){
// return Math.ceil(Math.random() * (max - min - 1)) + min;
// }
// [min,max)
// function getRandom(min,max){
// return Math.floor(Math.random()*(max-min))+min;
// }
// (min,max]
function getRandom(min,max){
return Math.ceil(Math.random()*(max-min))+min;
}
console.log(getRandom(5,10));
</script>