-1
我正在做一個筷子游戲,這是我正在做的第一個應用程序(真的是新的javascript),我想只要到達某一點,它就會重新啓動,直到敵人或手中有5把筷子。這裏是我的代碼:我想讓我的程序重新開始,有點像一個循環javascript
var nocLeft = 1;
var nocRight = 1;
var handChoice = prompt("You now have " + nocLeft + " chopstick(s) on your left hand, and " + nocRight+ " chopstick(s) on your right hand, which hand do you want to use?").toLowerCase();
if (handChoice === right){
var ehc = prompt("Which hand are you attacking? The enemy's left hand has " + noceLeft + ", and their right hand has " + noceRight + " chopsticks.").toLowerCase();
switch(ehc) {
case 'right':
console.log("You chose the right hand!");
break;
case 'left':
console.log("You chose the right hand!");
break;
default:
console.log("please answer with 'left' or 'right', thanks!");
}
}
else if (handChoice === left){
var ehc = prompt("Which hand are you attacking? The enemy's left hand has " + noceLeft + ", and their right hand has " + noceRight + " chopsticks.").toLowerCase;
}
else {
}
「循環」確實是正確的詞。查找「javascript循環」,並跳過w3schools鏈接。 – sbking
瞭解JavaScript。我們不是爲了爲您製作遊戲,只是幫助您瞭解您無法想象的代碼。 – PHPglue