title: Proper function placement
body: <p>Very new to programming and have a simple question about where to put more than one function i am trying to make a tic tac toe game and the function i am trying to place is </p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>function newgame()
  {
     var status = document.getElementById('status');
  
     xTurn = true;
     status.innerHTML = 'X\'s turn';
  
     for(var x = 0; x &lt; x++)
     {
        for(var y = 0; y &lt; y++)
        {
           document.getElementById(x + '_' + y).value = ' ';
        }
     }
  }</code></pre>
  </div>
  </div>
  </p>
  
  <p><strong>*Where would it go in here</strong> :
  <div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;!DOCTYPE html&gt;
  &lt;html&gt;
  &lt;head&gt;
  &lt;SCRIPT TYPE="TEXT/JAVASCRIPT"&gt;
  var xTurn = true;
  
  function squareclicked(square)
  // squareclicked is a function that is called whenever a button is clicked.
  {
   var status = document.getElementById('status');
   var value = square.value;
   if(value != 'X' &amp;&amp; value != 'O')
   {
     if(xTurn)
     {
        square.value = 'X';
        xTurn = false;
        status.innerHTML = 'O\'s turn';
     }
     else
        {
           square.value = 'O';
           xTurn = true;
           status.innerHTML = 'X\'s turn';
        }
   }
     else
        alert('That square has already been played.');
  }
  &lt;/SCRIPT&gt;
  
  &lt;body&gt;
  &lt;INPUT TYPE="BUTTON" ID="0_0" VALUE=" " ONCLICK="squareclicked(this);"&gt;
  &lt;INPUT TYPE="BUTTON" ID="0_0" VALUE=" " ONCLICK="squareclicked(this);"&gt;
  &lt;INPUT TYPE="BUTTON" ID="0_0" VALUE=" " ONCLICK="squareclicked(this);"&gt;
  &lt;BR&gt;
  &lt;INPUT TYPE="BUTTON" ID="0_0" VALUE=" " ONCLICK="squareclicked(this);"&gt;
  &lt;INPUT TYPE="BUTTON" ID="0_0" VALUE=" " ONCLICK="squareclicked(this);"&gt;
  &lt;INPUT TYPE="BUTTON" ID="0_0" VALUE=" " ONCLICK="squareclicked(this);"&gt;
  &lt;BR&gt;
  &lt;INPUT TYPE="BUTTON" ID="0_0" VALUE=" " ONCLICK="squareclicked(this);"&gt;
  &lt;INPUT TYPE="BUTTON" ID="0_0" VALUE=" " ONCLICK="squareclicked(this);"&gt;
  &lt;INPUT TYPE="BUTTON" ID="0_0" VALUE=" " ONCLICK="squareclicked(this);"&gt;
  &lt;BR&gt;
  &lt;INPUT TYPE="BUTTON" ID="NEWGAME" VALUE="New Game" ONCLICK="newgame();"&gt;
  &lt;P ID="status"&gt;X's turn&lt;/P&gt;
  &lt;/body&gt;
  &lt;/html&gt;</code></pre>
  </div>
  </div>
  </p>