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
Your code so far
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 information:
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
.
Link to the challenge: