Https://www.freecodecamp.com/challenges/return-largest-numbers-in-arrays

Https://www.freecodecamp.com/challenges/return-largest-numbers-in-arrays
0.0 0

#1

why it’s not taking my answer ? In javascript editor it shows exact output as it is. here is my code:

function largestOfFour(arr) {
var largest = [];
for(var i = 0; i<arr.length; i++){
var newArr = arr[i].sort(function(a,b) {return b - a;});
//console.log(newArr);
//console.log(newArr[0]);
largest.push(newArr[0]);

//console.log(arr[i]);

}
console.log(largest);
}

largestOfFour([[4, 5, 1, 3], [13, 27, 18, 26], [32, 35, 37, 39], [1000, 1001, 857, 1]]);

//////////////////////////////////////
Here is the screen shot:


#2

Your function isn’t returning anything. You are missing a return statement.


#3

your function is not returning…check the code and try inserting the return function


#4

exactly. now it works. Thanks man :blush: