Tell us what’s happening:
Describe your issue in detail here.

**Your code so far**

function multiplyAll(arr) {
var 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/91.0.4472.123 Safari/537.36

You can take a look at the description and they have an example using a nested loop - that’s a good place to start. There is more than one way to solve this, but that is definitely one way.

Thanks Kevin, I have a major brainDiskError every time I come across something new. I watched the video and read through the comments then wrote it out a few times. Makes sense now. Until I see it used in a slightly different way. My question is with regards to how the multiplication itself works.

Could you explain how we got to the number 5040? I’ve tried doing the number myself using a calculator but can’t get to the answer.

Join the club. Yeah, this is hard stuff, don’t be too hard on yourself.

Could you explain how we got to the number 5040?

For this input:

multiplyAll([[1,2],[3,4],[5,6,7]]);

the answer is 5040.

First of all, remember that multiplication (like addition) is commutative - it doesn’t matter what order it is, you can scramble it up and will always get the same result. In other words, we will get the same answer no matter what order we multiply them.

So, this is: 1 X 2 X 3 X 4 X 5 X 6 X 7. If you type that into a calculator, it is 5040. If you remember a little math, you’ll also know that this is the same as 7! - same result, 5040.

So, this is a pretty simple math problem. Perhaps you either mistyped something into the calculator. Or perhaps you misunderstood what is being done.

Does that clear things up or have I misunderstood the question?

No I am the one misunderstanding the question which is making it difficult to relay what I’m trying to understand if that makes sense.

let me try break down my thinking so I can explain to you what it is i am struggling with.

So lets start with the product value is arr[i][j],

var arr = [
for (var i=0; i < arr.length; i++)

so this would loop through the first array returning values of? 0 ,1, 2 as the arr.length is 3?

Then for the second part the value outputs of J would be what?

Then how would those multiply together. Sorry this is not making much sense. I feel highly incompetents right now just trying to explain this. Gonna go over it a few more times. I’m reading the comments but it’s just not clicking at all.

Wow, thank you very much! This makes absolute sense to me now. I have actually solved this puzzle before in a far more basic way on the Google Grasshopper app. Made total sense then, absolutely blew my mind now. This visual representation really makes it easy to understand the logic behind this. I don’t know why but my brain was trying to multiply the values within the different arrays to get to some answer. Meanwhile we’re just looping through two arrays [0][0] [0][1] [0][2] [1][0] [1][1] [1][2] taking those values then multiplying them onto the product variable. Tada. Sorry for my poor explanation , i have only been doing JS for ±100hours now. Mostly Udemy lectures and examples, which are great for intro but then I find the same question in a slightly different variant and my mind is blown.