title: Reset javascript function
body: <p>I am having trouble getting a javascript function to reset itself after an onclick event. When I click the "Start" button the counter begins to count up. But when I click the "Reset" button nothing happens. I need the timer to reset to "0:00" and wait for me to click "Start" again. Here is my code:</p>
  
  <pre><code>&lt;script type="text/javascript"&gt;
  var seconds = 0;
  var minutes = 0;
  
  function zeroPad(time) {
      var numZeropad = time + '';
      while(numZeropad.length &lt; 2) {
          numZeropad = "0" + numZeropad;
      }
      return numZeropad;
  }
  
  function countSecs() {
      seconds++;
  
      if (seconds &gt; 59) {
           minutes++;
           seconds = 0;
      }
      document.getElementById("timeBox").innerHTML = "Time " + zeroPad(minutes) + ":" + zeroPad(seconds);
  }
  
   function startTimer() {
       action = window.setInterval(countSecs,1000);
   }
  
  
  function resetTimer() {
      var seconds = 0;
      var minutes = 0;
   }
  
  &lt;/script&gt;
  
  &lt;body&gt;
  &lt;button onclick = "startTimer()"&gt;Start&lt;/button&gt;
  &lt;div id="timeBox"&gt;Time 00:00&lt;/div&gt;
  
  &lt;button onclick = "resetTimer"&gt;Reset&lt;/button&gt;
  &lt;/body&gt;
  </code></pre>