Javascript 在函数中,我有一个未捕获的SyntaxError:意外的标记else

Javascript 在函数中,我有一个未捕获的SyntaxError:意外的标记else,javascript,function,Javascript,Function,我已经多次遇到这个问题,我也读过其他帖子,但都没有发现我做错了什么。有人能帮忙吗 function switchTurn() { if (checkForWinner(document.turn)) { setMessage("Congratulations, " + document.turn + "! You win!"); } else if (document.turn === "X"); { document.turn = "O";

我已经多次遇到这个问题,我也读过其他帖子,但都没有发现我做错了什么。有人能帮忙吗

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!");
    }
   }
此处:

else if (document.turn === "X"); {
是错误的。

应该是:

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!");
    }
   }

堆栈溢出不是您的个人调试器。我们正试图建立一个好的问答库,这将在未来帮助人们。