title: Adding start, stop, and reset buttons for a timer
body: <p>I'm making a timer and have it working already one load. I want to add a start, stop, and reset button to it. This is my code as is atm.</p>
  
  <pre><code>    (function() {
           "use strict";
           var secondsLabel = document.getElementById('seconds'),
           minutesLabel = document.getElementById('minutes'),
           hoursLabel = document.getElementById('hours'),
           totalSeconds = 0,
           startButton = document.getElementById('start'),
           resetButton = document.getElementById('reset'),
           onOff = 0; 
           startButton.onclick = function() {
           onOff = 1;
       };
       resetButton.onclick = function() {
           totalSeconds = 0;
           onOff = 0;
       };
  
       if ( onOff == 1 ) {
           setInterval( setTime, 1000 );
           function setTime() {
           totalSeconds++;
           secondsLabel.innerHTML = pad( totalSeconds % 60 );
           minutesLabel.innerHTML = pad( parseInt( totalSeconds / 60 ) );
           hoursLabel.innerHTML = pad( parseInt( totalSeconds / 3600 ) )
       }
       function pad( val ) {
           var valString = val + "";
           if( valString.length &lt; 2 ) {
              return "0" + valString;
           } else {
              return valString;
           }
       }
     }
  
   })();
  </code></pre>
  
  <p>The buttons are not working atm however. I'm not sure if this the best solution for the goal as well, so suggestions are welcome.</p>