current code
priceHistory is object which has object.
Object {
"2020-05-17 10:43:45": Object {
"created_at": "2020-06-17 10:43:45",
"price": 1000,
},
"2020-05-17 10:43:51": Object {
"created_at": "2020-07-17 10:43:51",
"price": 2000,
},
"2020-05-17 10:43:56": Object {
"created_at": "2020-08-17 10:43:56",
"price": 3000,
},
"2020-05-17 10:44:01": Object {
"created_at": "2020-09-17 10:44:01",
"price": 4000,
},
}
Object.keys(priceHistory).forEach((history) => {
console.log(priceHistory[history]);
});
problem
When using forEach for priceHistory, console.log(priceHistory[history]);
outputs
Object {
"created_at": "2020-07-17 10:43:51",
"price": 2000,
}
Object {
"created_at": "2020-08-17 10:43:56",
"price": 3000,
}
Object {
"created_at": "2020-09-17 10:44:01",
"price": 4000,
}
Object {
"created_at": "2020-06-17 10:43:45",
"price": 1000,
}
The order of object has been changed. How can you solve this? created_at is string and price is number.
I would appreciate it if you could give me any advices.