Build the Largest Number Finder - Build the Largest Number Finder

Tell us what’s happening:

I don’t understand why the 3rd one doesn’t work like the others, coudl you help? Thanks.

Your code so far

function largestOfAll(arr){

let arr1 = arr[0];
let arr2 = arr[1];
let arr3 = arr[2];
let arr4 = arr[3];

let result = "";


for(let i = 0; i <= arr[0].length; i++){
let arr1max = arr1[0];
if(arr1[i] > arr1max){ arr1 = arr1[i];}
  console.log(arr1);
}

for(let j = 0; j <= arr[1].length; j++){
let arr2max = arr2[0];
if(arr2[j] > arr2max){ arr2 = arr2[j];}
  console.log(arr2);
}
 

for(let k = 0; k <= arr[2].length; k++){
let arr3max = arr3[0];
if(arr3[k] > arr3max){ arr3 = arr3[k];}
  console.log(arr3);
}

for(let l = 0; l <= arr[3].length; l++){
let arr4max = arr4[0];
if(arr4[l] > arr4max){ arr4 = arr4[l];}
  console.log(arr4);
} 

result = [arr1, arr2, arr3, arr4]

return result
 
 
}

 console.log(largestOfAll([[13, 27, 18, 26], [4, 5, 1, 3], [32, 35, 37, 39], [1000, 1001, 857, 1]]))
 

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/144.0.0.0 Safari/537.36 Edg/144.0.0.0

Challenge Information:

Build the Largest Number Finder - Build the Largest Number Finder

why do you do this followed by

first they are arrays then they are numbers?

what are these variables arrNmax for?

I try to replace each position with the max number, so I make arr1 = arr1[i].

I assume position[0] is the max number first, then compare each number as i goes up

but why give a start value of array to then assign a number?

and why create arr1max but then you don’t use it?

got it, thanks alot, I have solved it.