Skip to content

Instantly share code, notes, and snippets.

@mtroiani
Created December 12, 2015 00:38
Show Gist options
  • Save mtroiani/7656f50288befc965165 to your computer and use it in GitHub Desktop.
Save mtroiani/7656f50288befc965165 to your computer and use it in GitHub Desktop.
http://www.freecodecamp.com/mtroiani 's solution for Bonfire: Return Largest Numbers in Arrays
// Bonfire: Return Largest Numbers in Arrays
// Author: @mtroiani
// Challenge: http://www.freecodecamp.com/challenges/bonfire-return-largest-numbers-in-arrays
// Learn to Code at Free Code Camp (www.freecodecamp.com)
function largestOfFour(arr) {
var bigArr = [];
for (var i = 0; i < arr.length; i ++) {
var largest = 0;
for (var n = 0; n < arr[i].length; n ++) {
if (arr[i][n] > largest) {
largest = arr[i][n];
}
}
bigArr[i] = largest;
}
return bigArr;
}
largestOfFour([[13, 27, 18, 26], [4, 5, 1, 3], [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