Tell us what’s happening:
Hello!,
I have been able to solve this exercise, I understand how it works, but I cannot understand this product:
multiplyAll([[5, 1], [0.2, 4, 0.5], [3, 9]])
should return 54
**Your code so far**
function multiplyAll(arr) {
let product = 1;
// Only change code below this line
for (let i = 0; i < arr.length; i++) {
for (let 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]]);
function multiplyAll(arr) {
let product = 1;
// Only change code below this line
// Only change code above this line
return product;
}
multiplyAll([[1, 2], [3, 4], [5, 6, 7]]);
RESULT= 5040
I can understand well this pair of statements:
multiplyAll([[1], [2], [3]])
should return 6
(index of array products)
multiplyAll([[1, 2], [3, 4], [5, 6, 7]])
should return 5040
Classical mathematical resolution (a * b) * (c * d) …
But with this…
multiplyAll([[5, 1], [0.2, 4, 0.5], [3, 9]])
should return 54
I don’t understand where this arithmetic comes from! …
Can someone please clarify this question for me.
Thanks in advance!
**Your browser information:**
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/96.0.4664.110 Safari/537.36 Edg/96.0.1054.62
Challenge: Nesting For Loops
Link to the challenge: