2
我試圖在JavaScript中的文字冒險遊戲初學者,我需要直到用戶輸入一個有效的答案重複switch語句:重複switch語句,直到它有一個有效的答案
opts = prompt("Do you want to TALK or LOOK?").toUpperCase();
switch(opts) {
case "TALK":
mes = "Is anyone in charge here?";
speech = "Our leader is in the big building.";
talkNot();
break;
case "LOOK":
window.alert("The buildings are quite simple, and the doorways are much shorter than you. You notice, however, that there is a very tall, thin building at the end of the street.");
break;
default:
window.alert("That's not an option.");
}
任何答案會超級有幫助 - 謝謝!
對於案例:看看,默認你的邏輯是好的,對談話我猜你已經定義talkNot(),有什麼問題嗎? –