dimanche 30 novembre 2014

Breaking out of a while loop and switch in one go - JavaScript


I know a similar question has been posted concerning this in C++, but I'm focusing on JS here. I'm basically in the same situation as the C++ coder in the other post



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*/
}


Is there anyway to do that? Perhaps a JS version of the C++ solution. Break out of loop and switch in C++ question





Aucun commentaire:

Enregistrer un commentaire