title: How to set Interval , clear Interval and pass an argument (timer)
body: <p>documentation states that clearInterval() is required to be passed in a setIntervalId, therefore the function has to look like:</p>
  
  <pre><code>var logMe = setInterval(function () {...}, interval)
  </code></pre>
  
  <p>Above function is also being self-invoked as soon as the page loads.</p>
  
  <p>If i try to put it in an anonymous function as below:</p>
  
  <pre><code>var logMe = function (interval) {
      setInterval(function () {
          console.log("whatever");
      }, interval);
  };
  </code></pre>
  
  <p>I can pass an interval argument, but I cannot stop it with:</p>
  
  <pre><code>function stopLogMe() {
      window.clearInterval(logMe);
  };
  </code></pre>
  
  <p>So the question is, can I create a function "setInterval" that I can pass an argument (interval) and also stop it using clearInterval ?</p>