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:
https://www.freecodecamp.org/challenges/return-largest-numbers-in-arrays