I have some data and I want to split it twice. The data looks something like this:
var data = ['a1 b1 c1', 'a2 b2 c2Xa3 b3 c3Xa4 b4 c4', 'a5 b5 c5', 'a6 b6 c6Xa7 b7 c7', 'a8 b8 c8'];
As a first delimiter I use the 'X' character and this works fine:
var firstSplit = new Array(new Array());
for(var i = 0; i < data.length; i++)
firstSplit[i] = data[i].split('X');
But when I use the whitespace between the elements as a delimiter I get "Uncaught TypeError: Cannot set property '0' of undefined", on the line of the second split.
var secondSplit = new Array(new Array(new Array()));
for(var i = 0; i < firstSplit.length; i++) {
for(var j = 0; j < firstSplit[i].length; j++)
secondSplit[i][j] = firstSplit[i][j].split(' ');
}