What will be the output of the following recursive function?
function computeSum(arr) {
if (arr.length === 0) {
return 0;
}
let firstElement = arr[0];
let remainingArray = arr.slice(1);
if (Array.isArray(firstElement)) {
return computeSum(firstElement) + computeSum(remainingArray);
}
return firstElement + computeSum(remainingArray);
}
console.log(computeSum([1, [2, [3, 4]], 5]));