I have an array. It consists of 10 arrays.
var arr = [[], [], [], [], [], [], [], [], [], []];
Every of this 10 arrays has different number of numbers. I want to get last numbers in that 10 arrays.
I have tried to do such a way:
var lastNums = [];
var i = 0;
var j = 0;
for (var k = 0; k < 10; k++) {
i = arr[k].length - 1; //This code gets number of the last number
lastNums[j] = arr[k][i];
j++;
}
But it doesn't seems to work. In Chrome Console I get:
TypeError: Cannot read property 'length' of undefined
arr[k]and not an array