I am working with a javascript array containing values [A,B,C,D,E.....]
that needs to be split using the following syntax:
[ [A, B], [C, D], [E, F] ]
This splitting process should always result in pairs.
I attempted to achieve this using a loop to return a string, and here is my code snippet which almost accomplishes what I want:
text = '['+array[0]+','+array[1]+']';
for (index = 2; index < array.length; index++) {
text += '['+array[index]+','+array[index+1]+']';
console.log(text);
}
The current output displays:
[10:00,15:45][18:30,20:00]
[10:00,15:45][18:30,20:00][20:00,undefined]
But I actually need the output to be:
[10:00,15:45][18:30,20:00]