Created
June 15, 2017 13:03
-
-
Save 19h47/9cc05efbacc202fdd987c89b8bbf3b97 to your computer and use it in GitHub Desktop.
Create an array with largest number from sub 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 largestNumberOfArrays(array) { | |
return array.map( function (subArray){ | |
return subArray.reduce( function (previous, current) { | |
return (current > previous) ? current : previous; | |
}); | |
}); | |
} | |
// Used | |
largestOfFour([[4, 5, 1, 3], [13, 27, 18, 26], [32, 35, 37, 39], [1000, 1001, 857, 1]]); | |
// return [5, 27, 39, 1001] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment