This is my attempt and it works fine, but I need to return the array containing the largest number, not the largest number itself.
Also, I want to know if there is a way to use deep-equal to compare inner arrays in 2D arrays.
function largestOfFour(arr) {
for (var i = 0; i < arr.length; i++) {
var largest = [0][0];
for (var j = 0; j < arr[i].length; j++) {
if (arr[i][j] > largest) {
largest = arr[i][j];
}
}
}
return largest;
}
var largest = largestOfFour([
[4, 5, 1, 3],
[13, 27, 18, 26],
[32, 35, 37, 39],
[1000, 1001, 857, 1]
]);
console.log(largest);