Note. This is just for fun.
I was wondering why my console log statement returns undefined the product is returned right above? I have a quick read through a post on stack overflow but it didn’t make much sense to me https://stackoverflow.com/questions/15694273/console-log-not-printing-variable-from-function
Can somebody please clarify?
function multiplyAll(arr){
var product =1;
for (var i = 0; i < arr.length; i++){
for(var j=0; j < arr[i].length; j++)
product = product * arr[i][j];
}
return product;
}
//modify values below to test code
multiplyAll([[60,60],[24,365]]);
//why is the product undefined?
console.log(product)