Tell us what’s happening:
Describe your issue in detail here.
I am trying to use the sort method to sort out the individual arrays but for some reason, numbers greater than 3 digits like 1001 are not moving to the end of the arrays with sort. Please help!
**Your code so far**
function largestOfFour(arr) {
let myArray = [];
for (let i = 0; i < arr.length; i++) {
arr[i].sort();
for (let j = arr[i].length - 1; j >= 0; j--) {
myArray.push(arr[i][j]);
break;
}
}
console.log(myArray);
return arr;
}
largestOfFour([[4, 5, 1, 3], [13, 27, 18, 26], [32, 35, 37, 39], [1000, 1001, 857, 1]]);
largestOfFour([[13, 27, 18, 26], [4, 5, 1, 3], [32, 35, 37, 39], [999, 1001, 857, 1]])
**Your browser information:**
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36
Challenge: Return Largest Numbers in Arrays
Link to the challenge: