Tell us what’s happening:
Does this statement “product *= arr[i][j];” produce the following result?
product = [1x2]x[3x4]x[5x6x7].
I am just trying to figure out the logic here. Is this statement producing the result by taking the array and multiplying the elements as it is incremented? If the Product is = to 1 wouldn’t the x= return a value each time as 1x[i] or 1x[j] and not the product of the elements being multiplied by each other?
I know I am missing something very small here but can’t wrap my head around it. I think I just do not understand the x= operator and it’s relation to i++ and j++ for ex.
Your code so far
function multiplyAll(arr) {
var product = 1;
// Only change code below this line
for (var i=0; i < arr.length; i++){
for (var j=0; j < arr[i].length; j++){
product *= arr[i][j];
}
}
// 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/80.0.3987.163 Safari/537.36
.
Challenge: Nesting For Loops
Link to the challenge: