Javascript run a function inside a loop every x iterations
<p>I have a variable of unknown value, it will be an integer. For this sake, lets say <code>var a = 3;</code></p>

<p>I have a function that is called continuously:</p>

<pre><code>var a = 3;
function anim() {
        left = parseInt(galleryInner.css('left'), 10);   
        if(Math.abs(left) &gt;= (galleryItem.length * galleryItem.width())){
            galleryInner.css('left', 0);
        }
        galleryInner.animate({left: '-=20' }, 200, anim);

        that.appendEnd();
}
</code></pre>

<p>I'd like run this.appendEnd() only every 3 times, because <code>a === 3</code>.</p>

<p>How can I do this?</p>
