Attempt to add values to Array causes app to spin into an endless loop
<p>for some sick reason, my check productIDs[addIndex] = allProductIDs[lastProductFoundIndex + i]; causes my app to spin into an infinite loop:</p>

<p>numberOfImagesToDisplay is set to 4</p>

<pre><code>if (state == "next")
{
    for(var a = 0; a &lt; numberOfImagesToDisplay; a++) {
        alert("a=" + a + ", numImages=" + numberOfImagesToDisplay)

        if (a &gt; 0) { addIndex = productIDs.length + 1; }
        alert("I'm in GetNextProductIDs() 1");
        //var lastProductFoundIndex = $.inArray(lastProductID, allProductIDs);
        //alert("I'm in GetNextProductIDs() 2");

        if (lastProductIndex &gt;= 0) {
            alert("I'm in GetNextProductIDs() 3");
            //productIDs[addIndex] = allProductIDs[lastProductFoundIndex + i];
        }
    }
}
</code></pre>

<p>If I take out that line, it moves on.</p>

<p><strong>Update</strong>: Resolved. <code>lastProductIndex</code> was not defined. So what was happening is that it would get there and the loop would end but it's weird because a callback was being called again when it should have ended. So that callback method kept calling this method and this method would end at that spot, the callback method would again be called, and so you had an endless loop.</p>
