I have the following code:
const BOARD = { X: 3, Y: 5 };
const board = new Array(BOARD.X)
.fill(0)
.map((_, idx) =>
new Array(BOARD.Y).fill().map((elm, idx2) => (elm = `${idx},${idx2}`))
);
console.log(board)
And is printing in the console:
[
[ '0,0', '0,1', '0,2', '0,3', '0,4' ],
[ '1,0', '1,1', '1,2', '1,3', '1,4' ],
[ '2,0', '2,1', '2,2', '2,3', '2,4' ]
]
How can I invert the order of 'X' row, so it prints:
[
[ '2,0', '2,1', '2,2', '2,3', '2,4' ],
[ '1,0', '1,1', '1,2', '1,3', '1,4' ]
[ '0,0', '0,1', '0,2', '0,3', '0,4' ]
]