Hereâ€™s the same code, but much more verbose. Maybe it helps in understanding whatâ€™s happening:

function largestOfFour(arr, finalArr=[]){
// base case of recursion
if (arr.length === 0){
return finalArr
} else {
let maxOfSubArray = Math.max(...arr[0]); // biggest value in the first subarray
let newFinalArr = finalArr.concat(maxOfSubArray); // adds that value to the final array
let newArr = arr.slice(1); // newArr is arr but without the first subarray
return largestOfFour(newArr, newFinalArr)
}
}

In other words - in each step of the recursion

you look for the maximum in the first subarray

add that value to the final array thatâ€™s holding all the maximums

call the function again, with an array where the first subarray isnâ€™t present anymore

once that array is empty, you return the final array

I much prefer this solution though, it doesnâ€™t use fancy recursion but itâ€™s much clearer whatâ€™s happening:

function largestOfFour (arr, finalArray = []) {
if (arr.length === 0) {
return finalArray;
} else {
let currentSubarray = arr[0];
let largestValueInCurrentSubarray = Math.max(...currentSubarray);
// Push the largest value into the output:
finalArr.push(largestValueInCurrentSubarray);
// Now run the function again on the remaining subarrays:
let remainingSubarrays = arr.slice(1);
return largestOfFour(remainingSubarrays, finalArr);
}