I'm trying to make the simple code below works, but always got the following error: TypeError: cannot read property 'length' of undefined.
function multiplyAll(arr) {
var product = 1;
if (arr === undefined) {
return "Undefined Array!";
} else {
for (var i = 0; i < arr.length; i++) {
for (var j = 0; j < arr[i].length; i++) {
product *= arr[i][j];
}
}
return product;
}
}
multiplyAll([[7,2],[6,4],[5,8,9]]);
What is the problem?