Information: Hey, take a look at these 4 arrays, and then there's an array with those arrays nested inside. I'm using _.reduce to calculate the total length of all arrays combined. However, when I run the function with the array of arrays, I'm getting NaN instead of the expected result of 19.
Can anyone explain why this is happening? Your help is much appreciated!
var array1 = [[1],[2],[3],[4],[5]];
var array2 = ["a", "b"];
var array3 = [{name : "John"}, {age : 21}];
var array4 = [1,2,3,4,5,6,7,8,9,0];
var array5 = [array4, array3, array2, array1];
var arrayComboLength = function(array){
return _.reduce(array, function(a,b){
return a.length + b.length;
});
}
console.log(arrayComboLength(array5)); --> // NaN