Iterating over multidimensional arrays in JavaScript

Let the following two-dimensional array be given:

javascriptlet arr = [[1, 2, 3, 4, 5], [6, 7, 8], [9, 10]];

Let's output all its elements to the console. To do this, we need to run two nested loops:

javascriptlet arr = [[1, 2, 3, 4, 5], [6, 7, 8], [9, 10]];

for (let subArr of arr) {
  for (let elem of subArr) {
    console.log(elem);
  }
}
Задание 1

Given a 2D array of numbers:

javascriptlet arr = [[1, 2, 3], [4, 5], [6]];

Use nested loops to find the sum of this array elements.

Задание 2

Given a 3D array of numbers:

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

Use nested loops to find the sum of this array elements.