function largestOfFour(arr) {
const results = [];
for (let i = 0; i < arr.length; i++) {
let largestNumber = arr[i][0];
for (let j = 1; j < arr[i].length; j++) {
if (arr[i][j] > largestNumber) {
largestNumber = arr[i][j];
}
}
results[i] = largestNumber;
}
return results;
}
function largestOfFour(arr) {
return arr.map(function(group) {
return group.reduce(function(prev, current) {
return current > prev ? current : prev;
});
});
}
function largestOfFour(arr, finalArr = []) {
return !arr.length
? finalArr
: largestOfFour(arr.slice(1), finalArr.concat(Math.max(...arr[0])))
}