JavaScript 在两个数字之间随机
示例
返回介于min和之间的随机整数max:
function randomBetween(min, max) {
return Math.floor(Math.random() * (max - min + 1) + min);
}例子:
//randomBetween(0,10); Math.floor(Math.random() * 11); //randomBetween(1,10); Math.floor(Math.random() * 10) + 1; //randomBetween(5,20); Math.floor(Math.random() * 16) + 5; //randomBetween(-10,-2); Math.floor(Math.random() * 9) - 10;
热门推荐
10 新年门口花束祝福语简短
11 盘锦结婚祝福语大全简短
12 父母生日祝福语 简短独特
13 家庭恩爱祝福语简短英文
14 高考俄语祝福语大全简短
15 虎年祝福语 诗句唯美简短
16 生日婚礼祝福语简短精辟
17 虎年喝酒拜年祝福语简短
18 教师闺蜜祝福语简短