Tell us what’s happening:
So I’m not sure why this isn’t passing. Specifically, in the test shown, it pulls 13 from the first sub array and returns it as the biggest value for the second subarray.
I know this is probably not an efficient way to get to a solution, but it’s what I came up with on my own and the fact that it almost passed makes me happy! Any input as to why this isn’t working, as well as a better way to do/condense this, would be greatly appreciated!
Your code so far
function largestOfFour(arr) {
var biggest1 = 0;
var biggest2 = 0;
var biggest3 = 0;
var biggest4 = 0;
var result = [];
for (var i = 0; i < arr.length; i++) {
for (var j = 0; j < arr[i].length; j++) {
if (arr[0][j] > biggest1) {
biggest1 = arr[i][j];
}
if (arr[1][j] > biggest2) {
biggest2 = arr[i][j];
}
if (arr[2][j] > biggest3) {
biggest3 = arr[i][j];
}
if (arr[3][j] > biggest4) {
biggest4 = arr[i][j];
}
}
}
result = [biggest1, biggest2, biggest3, biggest4];
return result;
}
largestOfFour([[13, 27, 18, 26], [4, 5, 1, 3], [32, 35, 37, 39], [1000, 1001, 857, 1]]);