Missing results in my array
<p>I have an object which im converting into an array of coords which will be used to store which coords are "occupied".</p>

<p>I thought i had it working but on further inspection through console.log the array is missing a fair few results.</p>

<p>So this is basically my object:</p>

<pre><code>var sdata = {"4":{"7":["1","7","3","3"]}};
</code></pre>

<p>In words this is:</p>

<pre><code>var sdata = {"X":{"Y":["ID","ID","Width","Height"]}
</code></pre>

<p>Ignore ID for this as they are unrelated... but im trying to use this data so that i have the X and Y + the additional X and Y coords related to its tile dimensions width and height.</p>

<p>Imagine if you will the object for 4:7 is 3 by 3 dimensions so resulting in these 9 grid references would exist.</p>

<pre><code>[4:7], [5:7], [6,7]  
[4:8], [5:8], [6,8]  
[4:9], [5:9], [6:9]
</code></pre>

<p>So my function to create the coords is :</p>

<pre><code>function populate_collisions() {

  for (var X in sdata) {
    X = parseInt(X);

    for (var Y in sdata[X]) {
      Y = parseInt(Y);
      width = parseInt(sdata[X][Y][2]);
      height = parseInt(sdata[X][Y][3]);

  for (i=X; i!= X+width; i++) {

        if( typeof gcollision[i] == 'undefined' ) {
          gcollision[i] = new Array();
        }
        gcollision[i][Y] = 1

        for (j=Y; j!=Y+height; j++) {

          if( typeof gcollision[X] == 'undefined' ){ 
            gcollision[X] = new Array();
          }
          gcollision[X][j] = 1
        }
      }
    }
  }
}
</code></pre>

<p>But my logic must be wrong because im getting this result for my array:</p>

<pre><code>[4] [7] = 1
[4] [8] = 1
[4] [9] = 1
[5] [7] = 1
[6] [7] = 1
</code></pre>

<p>Any idea why im missing additional data?</p>
