Created
December 7, 2015 10:05
-
-
Save anonymous/44d46d2ca106e127fa95 to your computer and use it in GitHub Desktop.
http://www.freecodecamp.com/patrickcurl 's solution for Bonfire: Return Largest Numbers in Arrays
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
// Bonfire: Return Largest Numbers in Arrays | |
// Author: @patrickcurl | |
// 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) { | |
// You can do this! | |
var largest = []; | |
for(var i=0;i<arr.length;i++){ | |
largest[i] = arr[i][0]; | |
for(var j=0;j<arr[i].length;j++){ | |
if(arr[i][j] > largest[i]){ | |
largest[i] = arr[i][j]; | |
} | |
} | |
} | |
return largest; | |
} | |
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