I am having trouble with sorting the last nested array using arr[i].sort(). Despite trying various methods such as FOR and WHILE loops along with different operators, I still cannot achieve the desired result. Can someone help me identify what I am doing wrong? The goal is to return the largest numbers in the arrays.
function findLargestNumbers(arr) {
var i = 0;
while (i != arr.length) {
arr[i] = arr[i].sort().pop();
i++;
}
return arr;
}
findLargestNumbers([
[4, 5, 8, 1, 3],
[13, 27, 18, 26],
[32, 35, 37, 39],
[1000, 1001, 817, 1]
]);