Why does this give me a " TypeError: Cannot read properties of undefined (reading ‘length’) " error?
function multiplyAll(arr) {
var product = 1;
// Only change code below this line
for(var i=arr.length;i>=0;i--){
for(var j=arr[i].length;j>=0;j--){
product=product*arr[i][j];
}
}
// Only change code above this line
return product;
}
but not this one?
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;
}