Three-dimensional array in JavaScript

Here is an example of a 3D array:

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

To display elements from such an array, you already need to write three square brackets pairs:

console.log(arr[0][0][0]); // shows 'a' console.log(arr[2][1][0]); // shows 'k'

Given the following array:

let arr = [ [ [1, 2], [3, 4], ], [ [5, 6], [7, 8], ], ];

Referring to each element of the array, find the sum of all its elements.

enru