2
我正在做codecademy js課程,並且我正在用石頭剪刀剪刀。當我保存代碼時,它會顯示「SyntaxError:Unexpected token else」。我做錯了什麼? 這是我的代碼:Codecademy「SyntaxError:意外的令牌其他」
var compare = function(choice1, choice2)
{
if (choice1 === choice2)
{
return("The result is a tie!");
}
else if (choice1 === "rock")
{
if (choice2 === "scissors")
{
return ("rock wins");
}
else
{
return ("paper wins");
}
}
else if (choice1 === "paper");
{
if (choice2 === "rock")
{
return("paper wins");
}
else
{
return("scissors wins");
}
}
else if (choice1 === "scissors")
{
if (choice2 === "paper");
{
return ("scissors wins");
}
else
{
return("rock wins");
}
}
}