Does anyone know why my code isn’t working? I saw it was nearly the exact same as the solution and I couldn’t tell where I went wrong with the syntax
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[j][j];
}
// Only change code above this line
return product;
}
}
console.log(multiplyAll([[1,2],[3,4],[5,6,7]]));
Your browser information:
User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/85.0.4183.121 Safari/537.36.
The problem line of code has already been pointed out to you by @ilenia.
If you feel yourself copying the FCC solution might I add a piece of advice. I would pause on this problem and take a moment to understand how nested loops really work.
I would get out a pen and paper and write out what is really happening within the nested loops. Go step by step starting with the outer loop, checking if the condition is true and then moving inside the inner loop. Walk through each step carefully like a computer would and you will start to understand what is happening.