I am trying to get the largest number of each sub-array in the array I sorted them but I can't seem to get my result. The result should be an array of the largest number of each sub-array.
function largestOfFour(arr) {
for(var i = 0; i < arr.length; i+=1){
for(var n = 0; n < arr[i].length; n+=1 ){
arr[n].sort(function(a, b){return b-a});
}
console.log(arr[i][0]);
}
return arr[i][0];
}
largestOfFour([[4, 5, 1, 3], [13, 27, 18, 26], [32, 35, 37, 39], [1000, 1001, 857, 1]]);