i am a beginner in javascript and i have a litle problem.
I have this :
[
{
"date": "2014-04-23 00:00:00",
"volumetrie": "22458"
},
{
"date": "2014-05-02 00:00:00",
"volumetrie": "30585"
},
{
"date": "2014-03-27 00:00:00",
"volumetrie": "49536"
}
]
And i would like this :
[
{
"x": "2014-04-23T22:00:00.000Z",
"y": 22458
},
{
"x": "2014-05-02T22:00:00.000Z",
"y": 30585
},
{
"x": "2014-03-27T22:00:00.000Z",
"y": 49536
}
]
Do you have any ideas ? Thank you very much for you future answer ;)
Use Array.map:
var arr = [
{
"date": "2014-04-23 00:00:00",
"volumetrie": "22458"
},
{
"date": "2014-05-02 00:00:00",
"volumetrie": "30585"
},
{
"date": "2014-03-27 00:00:00",
"volumetrie": "49536"
}
];
var newArr = arr.map(function(item){
return {x: item.date, y: item.volumetrie};
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With