I couldn’t find the way to take first element from each array.
Any idea how it works?
function largestOfFour(arr) {
for (i = 0; i < arr.length; i++) {
arr[i] = arr[i].sort(function(a,b){return b - a;});
arr = arr.slice(0);
}
return arr;
}
largestOfFour([[4, 5, 1, 3], [13, 27, 18, 26], [32, 35, 37, 39], [1000, 1001, 857, 1]]);