【发布时间】:2015-07-06 07:53:54
【问题描述】:
我的 JavaScript 程序应该打印出用户给定的两个最大值和最小值之间的随机数。它适用于预先输入的数字,但只要我介绍获取最大值和最小值的提示,数字就会开始有趣地打印出来。
var min, max, hmany, i;
var n, w, ans, rsp;
min = prompt("Minimum number for addition problems");
//console.log(min);
max = prompt("Maximum number for addition problems");
//console.log(max);
hmany = prompt("How many questions do you want to answer?");
for (i = 0; i < 10; i++)
{
n = Math.floor(Math.random() * (max - min + 1)) + min;
console.log(n);
}
样本输出:(最小值为 1,最大值为 10)
21
61
71
51
41
01
01
11
21
11
【问题讨论】:
标签: javascript