Tell us what’s happening:
Why this code doesn’t work.
Just a note: please, don’t give the whole code. Just tell me why this code doesn’t work and what is the solution. That’s all. I tried another code before but this code specially just didn’t work and I don’t understand why.
Your code so far
function largestOfFour(arr) {
// You can do this!
var finalarray = [];
for (var i = 0; i < arr.length;i++) {
arr[i].sort(function (a,b) {
return a - b;
});}
for (var j = 0; j < arr[i].length;i++) {
var array = arr[i].pop();
finalarray = finalarray.push(array);
}
return finalarray;
}
largestOfFour([[4, 5, 1, 3], [13, 27, 18, 26], [32, 35, 37, 39], [1000, 1001, 857, 1]]);
Your browser information:
Your Browser User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:60.0) Gecko/20100101 Firefox/60.0
.
Link to the challenge:
https://www.freecodecamp.org/challenges/return-largest-numbers-in-arrays