title: javascript stopping a repeating setTimeout function
body: <p>I have a function that functions as a countdown timer for a simple pomodoro clock I'm building. Now I want to stop this function when the user clicks a reset function. I though I'd pass it a simple if statement that returns something and therefore terminates the function before the countdown iterates again but the function keeps on going. Any idea what's going on here is appreciated. Code below, can also check the whole thing on <a href="http://codepen.io/shooshte/pen/BjyrGb?editors=101" rel="nofollow">codepen</a>.</p>
  
  <pre><code>  function countdown(blocker) {
      if (blocker === true) {
        return true;
      } 
      else {
        setTimeout(function() {
          time -= 1;
          updateTimer();
          if (time &gt; 0) {
            countdown();
          }
        }, 1000);
      }
    }
  </code></pre>
  
  <p>calling the function like this doesn't stop it once it gets going:</p>
  
  <pre><code>countdown(true);
  </code></pre>