We have a function that is a piece of code with name multiplyAll and one parameter arr.
We are initializing var product to 1.
for loop normally has three arguments:
we are iterating from index 0 till index of arr.length adding 1:
index: 0, 1, 2, …, arr.length-1
We have multidimensional array:
if we look at example below
index0 contains array [1,2],
index1 contains array [3,4]
index arr.legth-1 contains array [5, 6, 7]
so we need a second for loop to iterate inside of that child arrays:
form index 0 till index arr[i].lenght:
if we look at example below
arr[0] is [1,2]
we are moving forwards so:
for arr[0] => [1,2], for arr[0][0] => 1
product * 1
product is initialized to 1, it means
1 * 1
product = 1
We are going back because we can go 1 step forward till we will find arr.length
product = 1
i = 0, because we have not reached arr[i].length-1
j = 1, because we are passed calculation with j= 0
for arr[0][1] =>2, product 1
product = 1 * 2
product = 2
i = 1, j = 0, product = 2 and so we are going…
After this all process our function returns a product.