function randomNum(minNum,maxNum){
  var choices = maxNum - minNum + 1;
  return Math.floor(Math.random() * choices + minNum);
}

var num = randomNum(2, 10);
alert(num);   //2-10的随机数(包括2或10);

posted on 2017-03-24 21:10  EnochRy  阅读(435)  评论(0编辑  收藏  举报