title: Reset a Count Up Timer in Javascript
body: <p>I have a count up timer and I want to create a reset button to start from 00:00
  This is my code:</p>
  <pre><code>&lt;label id=&quot;minutes&quot;&gt;00&lt;/label&gt;
                  &lt;label id=&quot;colon&quot;&gt;:&lt;/label&gt;
                  &lt;label id=&quot;seconds&quot;&gt;00&lt;/label&gt;
  </code></pre>
  <pre><code>setInterval(setTime, 1000);
  
  function setTime(){
      ++totalSeconds;
      secondsLabel.innerHTML = pad(totalSeconds%60);
      minutesLabel.innerHTML = pad(parseInt(totalSeconds/60));
  }
  
  function pad(val){
      var valString = val + &quot;&quot;;
      if(valString.length &lt; 2)
      {
          return &quot;0&quot; + valString;
      }
      else
      {
          return valString;
      }
  }
  
  // reset() function
  function resertTimer(){
      document.getElementById(&quot;minutes&quot;).innerHTML = &quot;00&quot;;
      document.getElementById(&quot;seconds&quot;).innerHTML = &quot;00&quot;;
  }
  </code></pre>
  <p>When I call the reset function, it changes the timer to 00:00 but then goes back to the previous value again. Like if the value was 00:15, it changes to 00:00 then goes back to 00:16</p>