Can't dynamically generate multidimensional array

Whats wrong with this code? i decalre resultArray as a new Array(). Then in a for loop for each resultCount i declare resultArray[resultCount] = new Array().
Then i try putting in values for every resultArray[y], but when i go to output the array in another function, everything in resultArray is undefined.

thanks in advance


function searchArray( arr ) {
	//search the array containing all database food items (foodArray), a 2 dimensional array.
	//find array entries that match search results.
	//put search results into 2 dimesional array foodArray.
	//display foodArray in output table.

	//re-intitialize resultArray to empty it, and resultCount to 0.
	resultArray = new Array();

	//set rows and columns dynamiically and for the output table
	//this uses foodArray to start.
	//only works if all rows of foodArray have the correct length, because always uses the first row to count length.
	arrayRows = arr.length;
	arrayColumns = arr[0].length;

	searchDone = true;
	resultCount = 0;	
	page = 1;
	
	//get search terms.
	food = document.getElementById("foodsearch").value;
	brand = document.getElementById("brandsearch").value;
	foodType = document.getElementById("foodtypesearch").value;

	//if a search term is entered for food
	if (food != "") {
		//for each row in the foodArray table
		for (var x = 0; x < arrayRows; x++) {
			//search the second column of each foodArray item for the search term.
			var result = arr[x][1].indexOf(food);
			//if a match was found, put the result into a new row for resultArray referred to by resultCount.
			if (result != -1) {
				for (var y = 0; y < arrayColumns; y++) {
					resultArray[resultCount] = new Array();
					resultArray[resultCount][y] = arr[x][y];
				}
				resultCount += 1;
			}
		}	

		fillTable( resultArray, page );
	}

i figured it out thanks