我正试图从if语句中打破for循环。 中断有效,并且不会继续迭代,但我的警报会被发布两次。为什么会这样?
sequence = 0;
keepGoing = true;
for (var p = 0; p < maxValue; p++) {
if (dataRecord[p].number <= sequence) {
alert("Something is not right! Try again");
keepGoing = false;
break;
}
else {
sequence = dataRecord[p].number;
alert("This one is ok!");
}
}
if (keepGoing) {
...
}
答案 0 :(得分:0)
这意味着for循环正在运行两次。