Last active
January 13, 2016 01:17
-
-
Save TravelingMan/e0cc20ae4222988d2a55 to your computer and use it in GitHub Desktop.
Build an array with the max value of another set of arrays. Uses Math.max.apply
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 getLargest(arr) { | |
var largestArr = []; | |
for (var i = 0; i < arr.length; i++) { | |
largestArr.push(Math.max.apply(null, arr[i])); | |
} | |
return largestArr; | |
} | |
getLargest([[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