I'm having trouble with this code:
Expected Exit:
detalhes:[{
01: 4570.00,
02: 4301.68,
03: 650.00,
12: 700.00,
}]
reality:
0:[{
{
mes: 4570.00,
},
{
mes: 4301.68,
},
{
mes: 650.00,
},
{
mes: 700.00,
}
}]
I did not understand why it does not print the value of the variable mes
var datas = {
"venda_detalhes": {
"2018-01-10 00:00:00": "4570.00",
"2018-02-15 00:00:00": "4301.68",
"2018-03-17 00:00:00": "650.00",
"2017-12-22 14:21:31": "700.00"
}
};
detalhes = [];
for (let prop in datas.venda_detalhes) {
let data = new Date(prop);
let mes = (data.getMonth() +1);
let value = datas.venda_detalhes[prop];
detalhes.push({mes : value});
}
console.log(detalhes);