Last active
April 3, 2016 22:11
-
-
Save ebragaparah/fd78e77a9b89d6817a986747a782f96f to your computer and use it in GitHub Desktop.
Find the largest number of each array inside another array
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function largestOfManyArrays(arr) { | |
function largestItemOfAnArray(arr) { | |
return arr.sort(function (a, b) { return b - a; }).shift(); | |
} | |
var largestOfEachArray = arr.map(function(array) { | |
return largestItemOfAnArray(array); | |
}); | |
return largestOfEachArray; | |
} | |
largestOfManyArrays([[4, 5, 1, 3], [13, 27, 18, 26], [32, 35, 37, 39], [1000, 1001, 857, 1]]); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I'm going to choose better names for the functions and the for the gist 😂