when if statement is true code goes to else?
<pre><code>if (_this.tiles["suz:SuzukiHubResponse"]["suz:categories"][category][aspect]["suz:image"][imageNo] != undefined) {
    if (imageNo &gt; (_this.tiles["suz:SuzukiHubResponse"]["suz:categories"][category][aspect]["suz:image"].length - 1)) {
        imageNo = 0;
        _this.categoriesCurrentImage[categoryIndex] = imageNo;
    }
    var img = _this.tiles["suz:SuzukiHubResponse"]["suz:categories"][category][aspect]["suz:image"][imageNo];

    _this.showImage(img, divId);
    _this.categoriesCurrentImage[categoryIndex]++;
    _this.categoryIndex++;
} else {

    if (imageNo &gt; (_this.tiles["suz:SuzukiHubResponse"]["suz:categories"][category][aspect]["suz:image"].length - 1)) {
        imageNo = 0;
        _this.categoriesCurrentImage[categoryIndex] = imageNo;
    }

    var img = _this.tiles["suz:SuzukiHubResponse"]["suz:categories"][category][aspect]["suz:image"];
    _this.showImage(img, divId);
    _this.categoriesCurrentImage[categoryIndex]++;
    _this.categoryIndex++;
}
</code></pre>

<p>Can anyone tell me why.</p>

<p>i end up in the else clause even though the if is true?
It makes absolutely no sense to me.</p>

<p>If there is more than 1 image underneath the suz:image node it should fall into the else.
it does 99% of the time.</p>
