Function returning undefined after first log
<p>I am trying to set up an image swapper function.  Here is my code so far:</p>

<pre><code>var imageChanger = function(start, end) {

var start = 1;
var end = 22;

return {
    count: function(url) {

        var self = this;

        if(start &gt; end) {
            start = 1;
        }

        console.log(url);
        console.log(start++);

        imageSwapper = setTimeout( function() {
            self.count();
        }, 2000)

    },
    stopCount: function() {
        clearTimeout(imageSwapper);
    }
}

}
</code></pre>

<p>As you can see, this is a function that takes two parameters.  It then returns an object of it's own with two methods.  When I call the <code>count</code> method after the initial <code>imageChanger</code> function call and pass a parameter to <code>url</code> it only logs what I pass one time and then when the <code>setTimeout</code> function runs, undefined subsequent times.</p>

<p>I am not sure what I am doing wrong here.  Why is this <code>count</code> function returning undefined after the first log??</p>
