I have a list which has some cities and has an empty object at the start. I need to set my empty object named best cities to an object which contains madrid like below. it should hold madrid key too in inside. I've tried to bestCity=cities.madrid but I lost the madrid key with this method. I wonder how to make this. Thank you.
cities: {
madrid: {
sunny: "yes",
capital: "yes"
},
london: {
sunny: "no",
capital: "yes"
},
miami: {
sunny: "yes",
capital: "no"
},
hamburg: {
sunny: "no",
capital: "no",
}
}
empty object at the start:
bestCity: {}
best city should be as below.
bestCity: {
madrid: {
sunny: "yes",
capital: "yes"
}
}
{bestCity : {...cities.madrid}}?