Initially, I have such an object
There is more data in it, I missed it
"Citizens": [
{
"_id": "6070be28c98d5a0ea88f131c",
"id": 1,
"name": "Karl",
"city_id": "1",
"groups": []
},
]
After passing through it in this cycle
for(let i = 0; i < objTmp[0]["Citizens"].length; i++){
for(let j = 0; j < citiesAll[0]["Cities"].length; j++){
if(objTmp[0]["Citizens"][i].id == citiesAll[0]["Cities"][j].id) {
objTmp[0]["Citizens"][i].city = citiesAll[0]["Cities"][j];
}
}
}
I add a city object from another object to it
I get such an object
"Citizens": [
{
"city": {
"id": 1,
"name": "Moscow",
"data": "10000000"
},
"_id": "6070be28c98d5a0ea88f131c",
"id": 1,
"name": "Karl",
"city_id": "1",
"groups": []
},
]
Question?
How can I add city not to the beginning, as shown here, but to the end?