You're running your loop one time too many.
Code:
var arr = ['A','B','C'];
arr.length; //3
for(var i=0; i < arr.length; i++){} // arr[0]: A, arr[1]: B, arr[2]: C
Code:
this.popMap = function()
{
tileset.makeTiles();
this.tileset = tileset.tile;
var yCount = 0;
var xCount = 0;
var swtch = 0;
for(i = 0; i < (this.mapData.length); i++)
{
var data = mapData[i]
switch (swtch)
{
case 0:
this.row[yCount] = document.createElement('tr');
this.map.appendChild(this.row[yCount]);
swtch = 1;
break;
case 1:
break;
case 2:
xCount = 0;
yCount++;
swtch = 1;
this.row[yCount] = document.createElement('tr');
this.map.appendChild(this.row[yCount]);
break;
}
xCount++;
if (xCount >= numCellsX)
{
swtch = 2;
}
this.row[yCount].appendChild(this.tileset[data]);
alert(this.row[yCount].tileset[i]);
//xCount++;
}
alert('done!!!');
}