Skip to content

Instantly share code, notes, and snippets.

@Hoxtygen
Created November 30, 2016 21:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Hoxtygen/cfae989e83dddc7023c80ef9fc139924 to your computer and use it in GitHub Desktop.
Save Hoxtygen/cfae989e83dddc7023c80ef9fc139924 to your computer and use it in GitHub Desktop.
A solution to FCC challenge
function largestOfFour(arr) {
// You can do this!
var result = [];
for (var i = 0; i < arr.length; i++) {
var largest = 0;
for (var j = 0; j < arr[i].length; j++) {
if (arr[i][j] > largest) {
largest = arr[i][j];
}
}
result[i] = largest;
}
return result;
}
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