title: Javascript, toggle a setInterval
body: <p>I'm trying to make a small script where the screen will randomly change it's background color every 100ms, and you can toggle this on and off by pressing a single button. I can get it to start, but I can't get it to stop. </p>
  
  <p>Here is the main code for toggling:</p>
  
  <pre><code>var on = -1;
  
  function change() {
      on = on*-1;
      if (on == true) {
          var light = window.setInterval(disco,100);
      }
      else {
          window.clearInterval(light);
      }
  }
  </code></pre>
  
  <p><code>disco</code> is the function that changes the background color. </p>
  
  <p>I've tried many different variations of this, but I think this is the closest I've gotten. Clicking the button now only set's another interval, despite the <code>on</code> variable correctly switching between 1 and -1. Am I not using clearInterval properly?</p>
  
  <p>The full JSFiddle is here: <a href="http://jsfiddle.net/VZdk9/" rel="noreferrer">http://jsfiddle.net/VZdk9/</a></p>
  
  <p>I'm trying to practice JavaScript, so no jQuery please :)</p>