I am trying to push the values [100,1000,10000,200,2000,20000,300,3000,30000] inside the multidimensional array in Javascript.
Multidimensional array should look like below
[[100,1000,10000],[200,2000,20000],[300,3000,30000]]
I am using the below code
var j = 0;
var x = 0;
var z = 0;
var f = new Array();
var rows = [100, 1000, 10000, 200, 2000, 20000, 300, 3000, 30000];
for (var i = 1; i <= rows.length; i++) {
if (j < i) {
f[x] = new Array();
var arrval = parseInt(rows[j]);
f[x][z] = arrval;
z++;
if (i % 3 == 0) {
x++;
z = 0;
}
j++;
}
}
But the push into multidimensional array push seems to be not working. The final output is looking like [[,,10000],[,,20000],[,,30000]]
Could you please help?
Thanks in advance