Skip to content

Instantly share code, notes, and snippets.

@NEbere
Created February 11, 2016 16:41
Show Gist options
  • Save NEbere/9475b5c7cd2c179890ac to your computer and use it in GitHub Desktop.
Save NEbere/9475b5c7cd2c179890ac to your computer and use it in GitHub Desktop.
Returns the largest number in each sub array
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