Hey all, for some reason when I run the below code as an answer to this challenge I do get the answers that the instructions say I should get.
However, when I run the test I’m failing on the 2nd through final challenges.
What could I be doing wrong here?
My only guess is I ended up doing the Functional Programming section out of order, so I applied the .map method here instead of using a normal for loop.
Your code so far
function largestOfFour(arr) {
let temp_arr = [];
temp_arr.push(arr.map(x => x.sort(function(a, b){return b-a})[0]));
return temp_arr;
};
console.log(largestOfFour([[4, 5, 1, 3], [13, 27, 18, 26], [32, 35, 37, 39], [1000, 1001, 857, 1]]));
console.log(largestOfFour([[13, 27, 18, 26], [4, 5, 1, 3], [32, 35, 37, 39], [1000, 1001, 857, 1]]));
console.log(largestOfFour([[4, 9, 1, 3], [13, 35, 18, 26], [32, 35, 97, 39], [1000000, 1001, 857, 1]]));
console.log(largestOfFour([[17, 23, 25, 12], [25, 7, 34, 48], [4, -10, 18, 21], [-72, -3, -17, -10]]));
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/77.0.3865.90 Safari/537.36
.
Link to the challenge: