我已经多次遇到这个问题并且我已经阅读了其他帖子,但无法找到我做错的事情。有人可以帮忙。
function switchTurn() {
if (checkForWinner(document.turn)) {
setMessage("Congratulations, " + document.turn + "! You win!");
} else if (document.turn === "X"); {
document.turn = "O";
setMessage("It's" + document.turn + "'s turn!");
} else {
document.turn = "X";
setMessage("It's" + document.turn + "'s turn!");
}
}
答案 0 :(得分:1)
;
此处:
else if (document.turn === "X"); {
错了。
答案 1 :(得分:0)
应该是:
function switchTurn() {
if (checkForWinner(document.turn)) {
setMessage("Congratulations, " + document.turn + "! You win!");
} else if (document.turn === "X"){
document.turn = "O";
setMessage("It's" + document.turn + "'s turn!");
} else {
document.turn = "X";
setMessage("It's" + document.turn + "'s turn!");
}
}