title: How to alert winner in Tic Tac Toe?
body: <p>I am having trouble trying to alert the winner, among other things. I also am trying to alert when the user trys to click on a button that has already been pressed, but have no idea what I am doing in that regard either. All help is appreciated. Thank you guys. </p>
  
  <pre><code>&lt;table&gt;
          &lt;tr&gt;
              &lt;td id="00" onclick="makeMove(0,0)"&gt;00&lt;/td&gt;
              &lt;td id ="01" onclick="makeMove(0,1)"&gt;01&lt;/td&gt;
              &lt;td id ="02" onclick="makeMove(0,2)"&gt;02&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td id ="10" onclick="makeMove(1,0)"&gt;10&lt;/td&gt;
              &lt;td id ="11" onclick="makeMove(1,1)"&gt;11&lt;/td&gt;
              &lt;td id ="12" onclick="makeMove(1,2)"&gt;12&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td id ="20" onclick="makeMove(2,0)"&gt;20&lt;/td&gt;
              &lt;td id ="21" onclick="makeMove(2,1)"&gt;21&lt;/td&gt;
              &lt;td id ="22" onclick="makeMove(2,2)"&gt;22&lt;/td&gt;     
   &lt;/tr&gt;
      &lt;/table&gt;
  
      &lt;hr&gt;
      &lt;input id="myMoveButton" type="submit"&gt;
  
      &lt;script src="java.js"&gt;&lt;/script&gt;
  </code></pre>
  
  <p>Javascript:</p>
  
  <pre><code>// -1 means 0's turn
  // 1 means X's turn
  
  // AFTER EVERY MOVE
  // UNTIL GAME OVER
  // THIS NEEDS TO BE FLIPPED
  // IF IT WAS 1, now it will be -1 and vice versa
  
  var turn = 1;
  
  // 0 means no move has been made yet 
  // on that particular square
  var grid = [
      [0, 0 ,0],
      [0, 0 ,0],
      [0, 0, 0]
  ];
  
  
  function makeMove(row, column) {
  
      if (grid [row][column] == 0) {
          grid[row][column] = turn;
  
          var idOfSquareToChange = row +"" + column;
  
          if (turn == 1) {
  
              $("#"+idOfSquareToChange).html('X');
          }else {
              $("#"+idOfSquareToChange).html('O');
          }
  
          // CHECK IF GAME IS OVER
  
          // IF GAME ISN'T OVER   
          if (turn == 1) {
              turn = -1;
          }else {
              turn = 1;
          }
          printGrid();
      }else {
          alert('That square has been chosen');
      }
  }
  
  function printGrid(){
  
      var board = grid[0][0] + " " + grid [0][1] + " " + grid[0][2];
      board += "\n";
      board += grid[1][0] + " " + grid [1][1] + " " + grid[1][2];
      board += "\n";
      board += grid[2][0] + " " + grid [2][1] + " " + grid[2][2];
  
      alert(board);
  }
  
  function isGameOver() {
      // HERE IS WHERE OUR LOGIC WOULD GO
      // TO SEE IF SOMEONE won
  
  }
  </code></pre>