# Basic JavaScript - Nesting For Loops

### Tell us what’s happening:

Describe your issue in detail here.

``````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]]);

``````

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)

What do you mean? Why do you think `product` should repeat individual numbers that are multiplied?

I don’t understand this Why introduce complex material if you don’t explain how it works in the first place?

Do you understand what `multiplyAll` function should do?

She must iterate over the array

Right, and what to do with the numbers in array?

multiply by product…

Multiply them, so if there are numbers `[[1, 2], [3, 4], [5, 6, 7]]`, the result is the result of multiplication: `1 * 2 * 3 * 4 * 5 * 6 * 7`

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.

`multiplyAll([[1], [2], [3]])` should return `6`

What’s `1*2*3`?

these are the values of arr[i]

No. The * symbol means multiplication. So, what is `1*2*3`?

This means you need to multiply arr[i][j]

Do the multiplication. `1*2*3=?`

yes I multiply by product = 1 this means the final result will be product = 3

No. Do you know how to multiply numbers together?

`1*2*3` is “one times two times three” which is 6.

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!

I know how arithmetic works, but I don’t know how javascript works, and no one on this forum has yet been able to explain anything to me

You don’t seem to know what `1*2*3` is if you multiply it out? If you can’t say what that arithmetic is, then this challenge is extremely difficult