我计算算术的次数> 5,现在正在计算,但是当数学< 5,我希望猴子重置为0.然后它将从0开始重新计数。
var monkey = 0;
function Normal() {
var math = Math.floor((Math.random() * 10) + 1);
if (math >= 5) {
monkey++;
console.log(monkey);
} else {
console.log("We")
}
}
<button onclick="Normal()">Hello</button>
答案 0 :(得分:0)
你错过了重置猴子
var monkey = 0;
function Normal() {
var math = Math.floor((Math.random() * 10) + 1);
if (math >= 5) {
monkey++;
console.log(monkey);
} else {
monkey = 0;
console.log("We")
}
}
<button onclick="Normal()">Hello</button>