私のコードは次のとおりです。誰かが存在しない名前を入力した場合、スイッチにループを張りたいです。私はJavaScriptが初めてで、仕事のためにJavaScriptを学習しています。これは私が練習するためだけに作っているものです。それは機能的に機能します、私はちょうどそれがデフォルトのケースを通過する場合、それをループさせる方法を見つけようとしています。ありがとう!私の同僚の名前を使用しないために、私はすべてのケースを自分の名前に変更しました。デフォルト時にループバックするスイッチを取得しようとしています
String.prototype.capitalizeFirstLetter = function() {
return this.charAt(0).toUpperCase() + this.slice(1);
}
var name = prompt("Please enter the name of the recipient to recieve a burn notice").toLowerCase();
switch (name) {
case 'brent':
case 'brent':
case 'brent':
case 'brent':
case 'brent':
case 'brent':
case 'brent':
case 'brent':
alert(name.capitalizeFirstLetter() + " has revieved a burn notice, ice is located downstairs in the freezer.");
break;
default:
alert("Didn't find " + name.capitalizeFirstLetter() + " please try again.");
}
なぜ7つの同じ「ブレント」ケースが空白になっていますか? –
私のケースすべてが同じアラートを受信するので、アラートが見つかるまでフォールスルーと呼ばれます。私はCodeschool.comを通して学びました –