title: Extend timeout function when button is clicked
body: <p>This piece of code works, but I am trying to get the timeout function to reset to '0' every time the button is clicked.</p>
  
  <pre><code>var running = false,
      count = 0,
      run_for = 700;
  
  
  var end_counter = function() {
      if (running) {
          running = false;
          $("#status").text("Not Running");
          alert(count);
          started_at = 0;
      }
  };
  
  $('button').click(function() {
      if (running) {
      count++;
  
  
      } else {
          running = true;
          $("#status").text("Running");
          count = 1;
          setTimeout(end_counter, run_for);
      }
  });
  </code></pre>