I have a question about the Inner Loops lesson:
https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/basic-javascript/nesting-for-loops
For the inner For Loop, I used
for (var j = 0; j < arr.length; j++)
In theory, shouldn’t this also work, since arr.length is 3? The solution tells me I need to use arr[i].length
The solution they gave was:
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;
}
// Modify values below to test your code
multiplyAll([[1,2],[3,4],[5,6,7]]);