Created
January 14, 2017 05:58
-
-
Save mijimoco/0eca8719f046bfb9b4aa44462be40f24 to your computer and use it in GitHub Desktop.
Return Largetst Numbers in Array
This file contains hidden or 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) { | |
// You can do this! | |
var newArray = [0,0,0,0]; | |
var largest = 0; | |
for (i=0; i < 4; i++) { | |
for (j=0; j < 4; ++j) { | |
if (arr[i][j] > newArray[i]) { | |
newArray[i] = arr[i][j]; | |
} | |
} | |
} | |
console.log(newArray); | |
return newArray; | |
} | |
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