title: JavaScript Infinite Loop help? Why is it happening?
body: <p>Edit: Here's a pastebin of the FULL code:
  <a href="http://pastebin.com/EVAyxh2N" rel="nofollow">http://pastebin.com/EVAyxh2N</a></p>
  
  <p>I've pasted my code below. If anyone can figure out why I'm getting an infinite loop from this, I'd love to see! Essentially, I have a for-loop inside of a foor-loop, and that worked fine, but I wanted to store rect data in an array so I could access it later, so I created another for-loop that deals with entries from the array, then creates rectangles for each of them.</p>
  
  <pre><code>// Create custom "tile" object
  function tileObj(x, y, img) {
      this.x = x;
      this.y = y;
      this.img = img;
  }
  
  // Create empty array to store tile data
  var tiles = [];
  
  // Create tile-grid, map.grid sized rectangles that will adopt tileset images
  function gridTiles() {
      for (var x = 0; x &lt;= map.width; x += map.grid) {
          for (var y = 0; y &lt;= map.height; y += map.grid) {
  
              var newTile = new tileObj(x, y, "red");
              tiles.push(newTile);
  
              for (var z = 0; z &lt; tiles.length; z++) {
                  tile = tiles[z];
                  ctx.rect(tile.x, tile.y, map.grid, map.grid);
                  ctx.fillStyle = tile.img;
                  ctx.fill();
              }
          }
      }
  }
  gridTiles();
  </code></pre>