lenadragon
New Member
So, I was having this problem with arrays in JavaScript.I initialized some variables as shown here: \[code\]var world = new Array;var monsters = new Array;var items = new Array;var x = 0;var y = 0;\[/code\]and tried to run this code on it: \[code\] while (y <= 49) { //generate world world[x][y] = parseInt(Math.floor(Math.random()*2)); //0 = flatland, 1 = desert, 2 = mountain, 3 = swamp x++; if (x >= 49) { x = 0; y++; } } x = 0; y = 0;\[/code\]but I get presented with this error: "TypeError: can't convert undefined to object"on the Math.random() line.I've tried everything I can think of, but it still throws that error.Any help will be greatly appreciated!