Tell us what’s happening:
so my problem is with the accumulator
see: freeCodeCamp Challenge Guide: Iterate Through an Array with a For Loop
in the previous one we used the total
which basiscallly means total = total + i
total += myArr[i]
so then since in this one we needed to add them together should’t it be :
product += [i] + [x];
or
a = a [i];
b = b[x];
product = a + b;
So why is this not working?
Your code so far
function multiplyAll(arr) {
var product = 1;
// Only change code below this line
for(var i = 0; arr.lenght; i++){
for (var x = 0; x <arr[i].length; x++){
product += [i] + [x];
}
}
// 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/86.0.4240.183 Safari/537.36
.
Challenge: Nesting For Loops
Link to the challenge: