I have this following object:
var d = {
"restaurant": 20,
"hotel": 40,
"travel": 60
}
And I need to transform it into this:
var a = [
{
"category_name": "restaurant",
"amount": 20
},
{
"category_name": "hotel",
"amount": 40
},
{
"category_name": "travel",
"amount": 60
}
]
This might be a silly question but as I am not a programmer I am facing this issue. Could some one help me at least pointing a direction for me to follow?
var d = { "restaurant": 20, "hotel": 40, "hotel": 60 }will be equal tovar d = { "restaurant": 20, "hotel": 60 }as there is no point of having duplicated keys in object, later one just overrides the former one