我正在尝试制作摇滚纸.. 游戏,但似乎代码仅在我打领带时才有效。我可能在下车的过程中搞砸了。另外我想问一下您填写的提示窗口上的数字是字符串还是数字?任何帮助表示赞赏。谢谢!
// rock beats scissors (1 beats 3)
// paper beats rock (2 beats 1)
// scissors beat paper (3 beat 2)
var player1= prompt("Player ONE, choose (1) for rock, (2) for paper, (3) for scissors");
var player2 = prompt("Player TWO, choose (1) for rock, (2) for paper, (3) for scissors");
function game (player1,player2)
{
if (player1===player2){
alert("its a tie");
}
else
{
if (player1+player2==="4")
{
if(player1==="1"){
alert("Rock beats Scissors, Player one wins");
}else {
alert("Rock beats Scissors, Player Two wins");
}
}
if (player1+player2==="3")
{
if (player1==="1"){
alert("paper beats rock, player One wins");
}else {
alert ("paper beats rock, player Two wins");
}
}
if (player1+player2==="5")
{
if (player1==="3"){
alert("scissors beats paper, Player One wins");
}else{
alert("scissors beats papaer, player Two wins");
}
}
}
};
game(player1,player2);