I want to create a 2D array, with varying width. I have initialized the outer array as I know the number of rows.
var listofcities = new Array(lengthofcites); //i get this lengthofcitles from another routine
Now, I will get the list of facilities in the cities from another routine as list. E.g. listoffacilities = ["water","air"]
for a city. For another city I will get this list as listoffacilities = ["water","air","electricity"]
.
I should be able to store this in my outer array in such a way that
listofcities[0] = ["water","air"]
listofcities[1] = ["water","air","electricity"]
I'm not able to use the push function like listofcities[0].push(listoffacilities)
in the inner loop.
All the examples I could see from web have same sized rows/columns.