How can I create two 2-DArrays where each element of array is an object with properties . Both arrays are of different size and property of each cell is different.
var gridcell = [];
var regionalcell = [];
So far I have done this, It works but its not efficient i dont want to repeat the code. It would be great if you guys can help.
In both functions value of "w,h,r,c" is different.
function createCellArray(w, h,r,c)
{
for (j = 0; j < r; j++)
{
gridcell[j] = [];
for (i = 0; i < c; i++)
{
gridcell[j][i] =
{
"x1": w * i,
"y1": h * j,
"x2": w * (i + 1),
"cell_color": null,
"y2": h * (j + 1),
"name": (i + 1 * (j * 10)) + 1
}
}
}
}
function createRegionalCellArray(w, h, r, c) {
for (j = 0; j < r; j++) {
regional[j] = [];
for (i = 0; i < c; i++) {
regional[j][i] =
{
"x1": w * i,
"y1": h * j,
"x2": w * (i + 1),
"cell_color": null,
"y2": h * (j + 1),
"name": (i + 1 * (j * 10)) + 1
}
}
}
}