title: jQuery - end setinterval after X rund
body: <p>I have a little slider im working on which is almost there im jsut having some trouble with me jQuery.</p>
  
  <hr>
  
  <p><strong>So first off:</strong>
  I want my slider to reset after the interval has run x amount of times.
  It was my understanding that the following would work but it doesn't seem to take. <code>6000, slides, function() { homesliderend();</code></p>
  
  <p>so lets say <code>slides = 2</code> set interval should call <code>homesliderend();</code> but it doesn't the interval just keeps running.</p>
  
  <hr>
  
  <p><strong>Second Issue:</strong> I'm also trying to get it to add 100% to <code>lengther</code> every 6 seconds. But instead of adding 100 each time its just setting it to 100 its not multiplying. </p>
  
  <p><div class="snippet" data-lang="js" data-hide="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>jQuery(document).ready(function($) {
    "use strict";
  
    function homesliderend() {
      $(".lengther").animate({
        left: "0%"
      }, 500);
    }
  
    function homeslider() {
      var slides = $(".slide.t-align").length,
        lwidth = slides * 100,
        n = 0;
  
      $(".lengther").css("width", lwidth + "%");
  
      setInterval(function() {
        var tn = n + 100;
        $(".lengther").animate({
          left: "-" + tn + "%"
        }, 500);
      }, 6000, slides, function() {
        homesliderend();
      });
  
  
    }
    homeslider();
  });</code></pre>
  </div>
  </div>
  </p>