Last active
September 30, 2015 23:26
-
-
Save waltzaround/c359f1c1a1bc0827f9ea to your computer and use it in GitHub Desktop.
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 end = []; // so we create an array called end | |
for(var a = 0; a < arr.length; a++){ // as we cycle through the sub-arrays that were given to us by arr... | |
var maximum = 0; // we create a variable called maximum | |
var inner = arr[a]; // we create a variable called inner.. it is equal in value to the selected arr array | |
for(var b = 0; b < inner.length; b++){ // as we cycle through the values in the selected array... | |
if (inner[b] > maximum) // if there is a higher value than what we have found... | |
maximum = inner[b]; // then the higher value that we found is now the highest value | |
} | |
end.push(maximum); // push the highest number out of the array | |
} | |
return end; // output the values in the end array out of the largestOfFour function | |
} | |
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