I have an issue, I have to sum the numbers in an array, and what I did works fine except in one situation :
sum([1, [2, 3, [4, 5], 6], 7, [8, 9]]) === 45
function sum(arr) {
var arrsum = 0;
for (var index = 0; index < arr.length; index++) {
if (!isNaN(arr[index])) {
arrsum += arr[index];
}
}
return arrsum;
}
The result for this one is 8, do you know how to make it 45 by only changing the function? Thanks a lot.