Created
February 11, 2016 16:41
-
-
Save NEbere/9475b5c7cd2c179890ac to your computer and use it in GitHub Desktop.
Returns the largest number in each 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 largestOfFour(arr) { | |
var results = []; | |
for (var n in arr) { | |
var largestNumber = 0; | |
for (var sb in arr[n]) { | |
if (arr[n][sb] > largestNumber) { | |
largestNumber = arr[n][sb]; | |
} | |
} | |
results[n] = largestNumber; | |
} | |
return results; | |
} | |
largestOfFour([[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