# Could someone help me on this code?

Tell us what’s happening:
I checked the solution and see they use " result[n] = largestNumber " to have the array with the largest number from the subarray. I don’t know their way before so I wrote my code as following, but it is not working. could someone help to explain why my code is not working? Thank you very much!

``````
function largestOfFour(arr) {
let maxArray = [];
for (let j = 0; j < arr[0].length; j++) {
let maxValue = arr[0][0];
if (arr[0][j] > maxValue) {
maxValue = arr[0][j];
}
maxArray.push(maxValue);
}
for (let j = 0; j < arr[1].length; j++) {
let maxValue = arr[1][0];
if (arr[1][j] > maxValue) {
maxValue = arr[1][j];
}
maxArray.push(maxValue);
}
for (let j = 0; j < arr[2].length; j++) {
let maxValue = arr[2][0];
if (arr[2][j] > maxValue) {
maxValue = arr[2][j];
}
maxArray.push(maxValue);
}
for (let j = 0; j < arr[3].length; j++) {
let maxValue = arr[3][0];
if (arr[3][j] > maxValue) {
maxValue = arr[3][j];
}
maxArray.push(maxValue);
}
return maxArray;
}

largestOfFour([[4, 5, 1, 3], [13, 27, 18, 26], [32, 35, 37, 39], [1000, 1001, 857, 1]]);

``````

User Agent is: `Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/84.0.4122.7 Safari/537.36`.
Take a look at where you put your `maxArray.push(maxValue)` statements. They exist in the “for” loop, so they are pushing max value for every iteration of the loop.
Running a `console.log(maxArray)` just before your `return` statement will help you debug this.