function arr2DTo1D(arr2d) {
const arr = new Array(arr2d.length * arr2d[0].length);
let k = 0;
for (let i = 0; i < arr2d.length; i++) {
for (let j = 0; j < arr2d[i].length; j++) {
arr[k++] = arr2d[i][j];
}
}
return arr;
}
const arr2d = [
[ 5, 6, 1, 4 ],
[ 3, 8, 0, 2 ],
[ 9, 2, 7, 3 ]
];
const arr = arr2DTo1D(arr2d);
arr.forEach(n => {
process.stdout.write(n + "\t");
});
/*
run
5 6 1 4 3 8 0 2 9 2 7 3
*/