function multiplyAll(arr){
var product=1
for (var i=0;i<arr.length;i++){
for (var j=0;j<arr[i].length;j++){
product=arr[i][j]*
}
}
return product
}
var product=multiplyAll([[1, 2], [3, 4], [5, 6, 7]])
console.log(product)
Could somebody please explain to me what is going on in the italicized statement(product*=arr[i][j])?
Can you please use the </>
button or put three backticks ```
on new lines before and after your block of code so that we can see it?
You have an array of arrays. The line product *= arr[i][j]
multiplies the current value of the product by the next entry in your array of arrays, specifically the i,j
entry.
You have an array called arr
. arr = ([[1, 2], [3, 4], [5, 6, 7]])
, so it is an array with sub-arrays.
Let’s say i=0
and j=0
for this example.
arr[i]
is arr[0]
which means the value at index 0 of arr
. That value is [1, 2]
.
arr[i][j]
is arr[0][0]
which means the value of index 0 at index 0 of arr
. That value is 1
.
Thank-you for helping me. So, the product is being multiplied by the the array j (index), and array i (counts the number of arrays). But if the array is being multiplied by the array, how does that work? The console would show up as NaN. Please explain further.

OHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHH. Welp, I’m dumb. Thanks a bunch
