Hi guys,
I’m having a real problem understanding this exercise. I KIND of get the nested loops concept, but I don’t get what we are producing by doing the following:
product = product * arr[i][j]
What’s happening with the arr[i][j] here!
I also have no idea what the actual answer is as we are given three different outcomes, and this one in particular is baffling:
multiplyAll([[5,1],[0.2, 4, 0.5],[3, 9]])
should return 54
Any help appreciated, thank you
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 = product * arr[i][j];
}
}
// Only change code above this line
return product;
}
multiplyAll([[1,2],[3,4],[5,6,7]]);
Challenge: Nesting For Loops
Link to the challenge: