First off, this code definitely works, but I know I need to use a for loop. I tried using a for loop and couldn’t quite get it. How would I convert this code to a for loop?
function largestOfFour(arr) {
// You can do this!
var newestArray = [];
var x = arr[0];
var y = arr[1];
var z = arr[2];
var aa = arr[3];
var newArray = x.sort(function(a, b) {return b - a;});
var newArray1 = y.sort(function(a, b) {return b - a;});
var newArray2 = z.sort(function(a, b) {return b - a;});
var newArray3 = aa.sort(function(a, b) {return b - a;});
var newerArray1 = newestArray.push(newArray[0]) + newestArray.push(newArray1[0]) +
newestArray.push(newArray2[0]) + newestArray.push(newArray3[0]);
return newestArray;
}
largestOfFour([[4, 5, 1, 3], [13, 27, 18, 26], [32, 35, 37, 39], [1000, 1001, 857, 1]]);