# Return Largest Numbers in Arrays- can't figure out what my mistake is

Return Largest Numbers in Arrays- can't figure out what my mistake is
0

#1

Tell us what’s happening:

I already checked out the solution, because I was confident in my answer and was pretty sure I’ve got a syntax problem here, but I couldn’t pin down exactly what I’m doing wrong…

I get whats going on in this challenge process wise, and I understand the solutio, but I’m concerned because I keep running into “cannot read property “__” of undefined” type errors and I’m pretty sure it’s syntax or format related(?).

So in this case I’m pretty sure the problem is rooted in the value of “arr[i][j]”, which I think should be the value of the first number in the first array, but apparently it’s actually not defined. I tried dot notation as well. Based on the solution the only possible difference I can see is that the solution uses “arr[n]” as the initial value for it’s large number place holder.
Does that make arr[n] ‘defined’ in a way that my code does not?

Again, I’ve encountered this kind of issue before, with subindexes especially, so if I’m making the same mistake over and over again I wanna make sure I avoid this problem in the future…
Thanks

``````function largestOfFour(arr) {
// You can do this!
var array=[];
var holder=0;

for (i=0; i<=3; i++);{

for(j=0; j<=3; i++);{
if(arr[i][j]>holder);{
holder=arr[i][j];

}
array[i]=holder;
}
}

return array;
}

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

Your Browser User Agent is: `Mozilla/5.0 (Windows NT 6.3; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/61.0.3163.100 Safari/537.36`.

#2

UPDATE:
So, convinced that this was a syntax problem I just wiped it and typed it out from scratch.
I made a couple tweaks, but I can not see what the significant difference is and it’s making me kinda batty.
Any skilled eyes out there? I keep doing this thing, whatever it is so please help me out.
Cheers

function largestOfFour(arr) {
// You can do this!
var array=[];

for(i=0 ; i < 4; i++){
var holder= arr[i][0];
for(j=0 ; j <4; j++){
if(arr[i][j] > holder) {
holder=arr[i][j];
}

``````}
array[i]=holder;
``````

}
return array;
}

#3

I failed to make it clear that the second version passed the challenge, oops!