perform function after x number of calls with setInterval
<p>In <a href="http://stackoverflow.com/a/2956980/1252748">this article</a>, the following function is given to perform an operation <em>x</em> times with setInterval()</p>

<pre><code>setIntervalX(function () {
    animateColor();
    //or something
}, 3000, 4);

function setIntervalX(callback, delay, repetitions) {
    var x = 0;
    var intervalID = window.setInterval(function () {

        callback();

        if (++x === repetitions) {
            window.clearInterval(intervalID);
        }
    }, delay);
}
</code></pre>

<p>what does the callback() do here? I'm trying to do a function after the specified number of repetitions is complete. but this</p>

<pre><code>setIntervalX(function () {
    animateColor();
}, 3000, 4, function(){

completeFunction();

});
</code></pre>

<p>does not work. Perhaps that syntax is very wrong. I was under the impression that using jquery, you could string together functions like that..</p>

<p>Much grateful for any insight. Thanks!</p>
