I am trying to push multiple values in array like
arr.push({y: val.date})
for(var n = 0; n < 4; n++) {
arr.push({'"+val+n+"': data["+n+"]});
}
Result is like:
[
{
"y": "2019-09-08 16:41:04"
},
{
"D0": "31.70"
},
{
"D1": "31.70"
},
{
"D2": "31.70"
},
{
"D3": "31.80"
}
]
But i want array to look like this:
{
"y": "2019-09-08 16:41:04",
"D0": "31.70",
"D2": "31.70",
"D3": "31.70",
"D4": "31.80"
}
I tried to merge and concatenate but its not working. Is there any way because my key & values are generated dynamically with json data.
Below code comes from other source that is why i had to do it like that
arr.push({y: val.date})