Hello,
Welcome to the new forum I guess. This is my first venture in the new format so bear with me.
I am working through the lessons in order in the FreeCodeCamp curriculum and I have come upon a lesson on nesting for loops that is giving me fits. I don’t want so much to be fed the answer but I need an explanation of what’s going on here.
So, Here’s my code:
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++){
console.log(arr[i][j]);
}
}
product = product * ?????;
// Only change code above this line
return product;
}
// Modify values below to test your code
multiplyAll([[1,2],[3,4],[5,6,7]]);
What I understand is that there is a function called multiplyAll which takes an arguement(arr) I understand the nested for loops I think. The argument (arr) actually takes more than one paramenter or argument: like this [i,j] So the first for loop finds the i’s and the second one finds the j’s and and the console.log statement is supposed to multiply i and j together and multiply those products. Or I’m wrong about that.
In the answer to the problem product needs to be equal to all the products multiplied together. But the product= statement has me buffaloed.
So if you could help with the answer and an explanation of what I’m missing I’d be grateful
All the best,
luciano991
