title: How can I change global variables in javascript?
body: <p>My html page displays a button that calls a function when it is clicked. I checked to make sure that the button works properly by displaying a message when clicked and it worked. I created this function to change the global varible but when I click another button on my html page to show the value of the varibles the varibles have not changed to the value I set them using my function. Could someone find the problem in my code below?</p>
  
  <pre><code>    var a = 5;
      var b = 16;
      var c = 27;
  
      function reset(){
      a = 0;
      b = 0;
      c = 0;
      }
  </code></pre>
  
  <p>My html code to call the function:</p>
  
  <pre><code>   &lt;!DOCTYPE HTML&gt;
  
     &lt;html&gt;
     &lt;center&gt;
     &lt;script type="text/javascript" src="game.js" &gt; &lt;/script&gt;
     &lt;form&gt;
     &lt;input type="button" value="Reset Variables" style="width:250px;height:50px" onclick="reset()" &gt;
     &lt;/form&gt;
     &lt;/html&gt;
  </code></pre>
  
  <p>Javascript code to show the variables:</p>
  
  <pre><code>    function display(){
  
      document.write("A is equal to " + a + "&lt;br/&gt;");
      document.write("B is equal to " + b + "&lt;br/&gt;");
      document.write("C is equal to " + c );
  
  }
  </code></pre>
  
  <p>Html to display the variables</p>
  
  <pre><code>   &lt;!DOCTYPE HTML&gt;
  
     &lt;html&gt;
     &lt;center&gt;
     &lt;script type="text/javascript" src="game.js" &gt; &lt;/script&gt;
     &lt;form&gt;
     &lt;input type="button" value="Show Variables" style="width:250px;height:50px" onclick="display()" &gt;
     &lt;/form&gt;
     &lt;/html&gt;
  </code></pre>