Hi,
I’m trying to solve a challenge problem, this one : https://www.freecodecamp.org/challenges/return-largest-numbers-in-arrays
I used this logic :
function largestOfFour(arr) {
// You can do this!
return arr.filter(a => {
return a.sort((b, c) => c-b)[0];
})
.reduce(function (flat, toFlatten) {
return flat.concat(toFlatten);
}, []);
}
largestOfFour([[4, 5, 1, 3], [13, 27, 18, 26], [32, 35, 37, 39], [1000, 1001, 857, 1]]);
For me, it should do the job, return what the sentence want, but it’s not the case, can someone tell me where is my mistake please ?
Thank you !