I have this array in the format.
var data = [{
"Month": "Jan 2017 - Check",
"balance": "0.00"
}, {
"Month": "Jan 2017 - Check",
"balance": "0.00"
}, {
"Month": "Feb 2017 - Check",
"balance": "0.00"
}, {
"Month": "Feb 2017 - Check",
"balance": "0.00"
}, {
"Month": "Mar 2017 - Check",
"balance": "0.00"
}, {
"Month": "April 2017 - Check",
"balance": "0.00"
}, {
"Month": "May 2017 - Check",
"balance": "0.00"
}, {
"Month": "May 2017 - Check",
"balance": "0.00"
}, {
"Month": "June 2017 - Check",
"balance": "0.00"
}, {
"Month": "July 2017 - Check",
"balance": "0.00"
}, {
"Month": "Aug 2017 - Check",
"balance": "0.00"
}, {
"Month": "Sept 2017 - Check",
"balance": "0.00"
}, {
"Month": "Oct 2017 - Check",
"balance": "0.00"
}, {
"Month": "Nov 2017 - Check",
"balance": "0.00"
}, {
"Month": "Dec 2017 - Check",
"balance": "0.00"
}, {
"Month": "Dec 2017 - Check",
"balance": "0.00"
}]
var label = [];
for (var i = 0; i < data.length; i++) {
var label1 = [];
var label1 = [];
label1.push(data[i].Month.split('-')[0].trim().split(" ").join(','));
label.push(label1);
}
console.log(label)
And I want to get the format
[
["June", "2015"], "July", "August", "September", "October", "November", "December", ["January", "2016"], "February", "March", "April", "May"
]
What I want is for array with space to be in another array. Reason for this is that I will use in chartJS.
What I get so far is
[
[
"Jan,2017,-,Check"
]
]
This should look like
[
[
"Jan","2017","-","Check"
]
]
Please ignore the - Check I will trim it but I have still error for now if there element is not .trim() My focus is create the same format of array
2015in["June", "2015"]? You need to provide more info."July 2017 - Check"i will trim it using.split('-')[0]gettingJuly 2017and then I want to get["July","2017"]but what I get is["July,2017"]I hope this is clear please comment if not["July,2017"]and strings e.g."July"? What determines if the element should be an 2-piece array vs a string?