Two Dimensional Arrays
Visualizing Two Dimensional Arrays
Whereas, one dimensional arrays can be visualized as a stack of elements, two dimensional arrays can be visualized as a multicolumn table or grid.
For example, we could create a two dimensional array that holds three columns of data; a question, an answer, and a topic.
|Two Dimensional Array|
|0||Arrays||What is an array?||An ordered stack of data|
|1||Arrays||How to create arrays?||Assign variable name to array object, then assign values to the array.|
|2||Arrays||What are two dimensional arrays?||An ordered grid of data|
Creating Two Dimensional Arrays
To do this, you create an array, loop through the array, and for each element, you create another array. Then, you simply add an index for each column of your grid. In JavaSript this would look something like this: