function multiplyAll(arr) {
let product = 1;
// Only change code below this line
// Only change code above this line
return product;
}
multiplyAll([[1, 2], [3, 4], [5, 6, 7]]);

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/118.0.5993.2470 YaBrowser/23.11.0.2470 Yowser/2.5 Safari/537.36

Challenge Information:

Basic JavaScript - Nesting For Loops

function multiplyAll(arr) {
let product = 1;
// Only change code below this line
for(let i = 0; i< arr.length; i++){
for(let j = 0; j<arr[i].length; j++){
product = product * arr[i][j]
}
console.log(product)
}
// Only change code above this line
return product;
}
multiplyAll([[1, 2], [3, 4], [5, 6, 7]]);

As always, it’s unclear where these numbers came from 2
24
5040? I thought that it should be output like this: 1,2,3,4,5,6, how can you understand anything here? It’s hard)

Something I don’t understand is how this happens: product = 1, which means everything needs to be multiplied by one, all six elements, but why do this?

Numbers are multiplied one-by-one, so there are two ways. Either set the initial result as 1, because multiplication of the first number by 1 will not change it value. Or set it as the result of multiplication two first numbers. I’m assuming first one is picked due to convenience.

but how did such a result come about 24
5040? if the product = 1, as far as I know, if multiplied by 1 * 6 it will be 6, but how you got such values is still a mystery to me.

If you do not know arithmetic, you should learn some arithmetic first. It’s ok if you don’t know how arithmetic works, but it’s pretty important to know how addition, subtraction, and multiplication work for programming so you should learn!