My code works, but my spidey-sense is telling me that in a more complicated scenario it would lead to problems. What those problems are, I’m not sure of. I was just hoping someone really smart could tell me why it’s a bad idea, despite being functional.
function largestOfFour(arr) {
let maxArray = [arr[0][0], arr[1][0], arr[2][0], arr[3][0]];
for (let i=0; i<arr.length; i++){
for (let j=0; j<arr[i].length; j++){
if(arr[i][j] > maxArray[i]){
maxArray[i]=arr[i][j];
}
}
}
return maxArray;
}
largestOfFour([[4, 5, 1, 3], [13, 27, 18, 26], [32, 35, 37, 39], [1000, 1001, 857, 1]]);