How would a loop be constructed to iterate all items of a 2D array in reverse, and diagonally? For example, iterating in that way with the following 2D array, would output the result below:

2D Array

[
  ['a', 'b', 'c'],
  ['d', 'e', 'f'],
  ['g', 'h', 'i'],
  ['j', 'k', 'l']
]

Output

l
k, i
j, h, f
g, e, c
d, b
a

The 2D array can be rectangular, not limited to square (2x2, 3x2, 2x3, etc.). How would I go about implementing a loop like that?

closed as off-topic by Josh Nov 8 at 21:49

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "Programming questions that aren't specific to game development are off-topic here, but can be asked on Stack Overflow. A good rule of thumb is to ask yourself "would a professional game developer give me a better/different/more specific answer to this question than other programmers?"" – Josh
If this question can be reworded to fit the rules in the help center, please edit the question.

  • 1
    What have you tried so far? – S4NNY1 Nov 8 at 20:34