I have a json array which looks like this:
data: Array(8)
0: (3) ["test1", "4.96", "150"]
1: (3) ["test2", "156.16666666666666", "150"]
2: (3) ["test3", "279.3695652173913", "92"]
3: (3) ["test4", "1718", "16"]
4: (3) ["test5", "2.375", "16"]
5: (3) ["test6", "2230.6875", "16"]
6: (3) ["test7", "23.75", "32"]
I have a method to split the array:
data.forEach(test => {
result.run.data.push([
Number(test[0].split('test')[1]),
Number(test[1])
]);
result.count.data.push([
Number(test[0].split('test')[1]),
Number(test[2])
]);
});
As you can see, i split the array at "test". My problem is, the test-string could be different. I want the same mapping to be done when the json looks slightly different although has the same structure.
For example the json array looks like this:
data: Array(8)
0: (3) ["asdf1", "4.96", "150"]
1: (3) ["fasd2", "156.16666666666666", "150"]
2: (3) ["qwer3", "279.3695652173913", "92"]
3: (3) ["llll4", "1718", "16"]
4: (3) ["rwwe5", "2.375", "16"]
5: (3) ["ttgd6", "2230.6875", "16"]
6: (3) ["34227", "23.75", "32"]
I would like it to split the same way as i do the first array.
How can i change my method to split the array at the start of each row instead of a string?