Return Largest Numbers in Arrays-Need Help

Return Largest Numbers in Arrays-Need Help
0

#1

I am trying to count the length of subarray at index 0. I implemented this logic written below but i got error TypeErrror: Cannot read property ‘length’ of undefined.
I know that solution does exist of this challenge but i want to do it myself. Thats why asking for help.

My code so far

function largestOfFour(arr) {
  
  var i;
  var realarr=[];
  var sublength=[];
  realarr=arr;
  for(i=0;i<5;i++) {
    sublength=realarr[i].length;
    
  }
  
  return sublength;
}

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/64.0.3282.140 Safari/537.36.

Link to the challenge:


#2

You need to review your for loop expression. Remember, that arrays are zero-indexed, so an array of 4 elements will only have the following indices: 0, 1, 2, 3


#3

Thanks randelldawson. so kind. always helping me. appreciated