I'm trying to create a function that sums the total of all the values in an array, even if those values are nested within nested arrays. Like this: countArray(array); --> 28 (1 + 2 + 3 + 4 + 5 + 6 + 7) I tried this recursive function, but it just concatenates.
var countArray = function(array){
var sum=0;
for(let i=0; i<array.length; i++){
if(array[i].isArray){
array[i]=countArray(array[i]);
}
sum+=array[i];
}
return sum;
}