【发布时间】:2015-01-28 21:49:12
【问题描述】:
在 C++ 中有一个关于这个问题的similar question,但我在这里使用的是 JavaScript。 我基本上和另一篇文章中的OP处于相同的情况。
var input = prompt();
while(true) {
switch(input) {
case 'hi':
break;
case 'bye':
//I want to break out of the switch and the loop here
break;
}
/*Other code*/
}
有没有办法做到这一点?
我在 /*Other code*/ 部分也有多个开关,代码也应该中断。
【问题讨论】:
标签: javascript while-loop switch-statement break