Loading [MathJax]/jax/output/HTML-CSS/fonts/TeX/fontdata.js

Nesting arrays

As you probably have noticed until now arrays can store multiple values in one place under one variable. Later we can grab these elements by specifying the index of the array to return a specific element from the given position. 

Arrays can store multiple values of various data types like strings, numbers, boolean and of course other arrays.

Nested arrays are possible and elements can be accessed as the example indicates above by implementing double square brackets. The first square brackets find the element inside the outer array, if the element at the given position is also an array that holds multiple values, then specific values of this nested arrays can be accessed by simply typing a second pair of square brackets, directly after the first one! 

On the example above, if we want to compare the two test results between two students, we need to first access them. As we can see the first result lies, at position 0 of the outer array, which happens to be an array that holds a name and the score. Then the score lies at the second position and can be accessed by index 1. The same functionality can be applied in order to grab  the next element score with the correct indexes ([1][1]).