仅在询问后显示下一个工作日
display next weekday only after asking
我在理解如何解决这个问题时遇到了一些问题。像这样循环输出星期几:“星期几。你想看下一天吗?”以此类推只要用户点击确定即可。
var a = ['Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday'];
var again = false;
do {
var question = prompt("Do you want to see the next day? (Yes / No)");
if (question == 'Yes') {
array();
var question;
again = true;
break;
}
} while (!again);
function array() {
for (i = 0; i < a.length; i++) {
console.log(a[i]);
}
}
您应该检查真实控制台以逐步查看输出。
Whosebug没有一步步输出。
var idx = 0;
var a = ['Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday'];
var again = false;
while (true) {
var question = prompt("Do you want to see the next day? (Yes / No)");
again = (question == 'Yes');
if (again) {
idx++;
console.log(a[idx]);
} else {
break;
}
}
我在理解如何解决这个问题时遇到了一些问题。像这样循环输出星期几:“星期几。你想看下一天吗?”以此类推只要用户点击确定即可。
var a = ['Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday'];
var again = false;
do {
var question = prompt("Do you want to see the next day? (Yes / No)");
if (question == 'Yes') {
array();
var question;
again = true;
break;
}
} while (!again);
function array() {
for (i = 0; i < a.length; i++) {
console.log(a[i]);
}
}
您应该检查真实控制台以逐步查看输出。
Whosebug没有一步步输出。
var idx = 0;
var a = ['Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday'];
var again = false;
while (true) {
var question = prompt("Do you want to see the next day? (Yes / No)");
again = (question == 'Yes');
if (again) {
idx++;
console.log(a[idx]);
} else {
break;
}
}