So i had to look at the solution my answer wasn’t far off, i just forgot to set product variable at the start and also i was thinking more like product = arr[i] * arr[j] which i myself know its weird writing it this way, thats why I looked it up.
now for the second(inner) loop if i console log it by itself this is what it returns
[ 1, 2 ]
[ 3, 4 ]
[ 1, 2 ]
[ 3, 4 ]
[ 1, 2 ]
[ 3, 4 ]
[ 5, 6, 7 ]
can anyone make sense of it for me, like why return number repeatedly and 5 6 7 just return once why is that?
I know what to do but i just want to understand the 2nd inner loop output. if someone would explain that would be great
function multiplyAll(arr) {
// Only change code below this line
let product = 1;
for(let i = 0; i < arr.length; i++){
for(let 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/88.0.4324.182 Safari/537.36
.
Challenge: Nesting For Loops
Link to the challenge: