I have an array called Cars. How do I get from this:
[
{
"id": 1,
"type": "Car",
"maxPerson": 4,
},
{
"id": 2,
"type": "Car",
"maxPerson": 5,
}
]
to this.
[
{
"id": 1,
"type": "Car",
"maxPerson": 4,
"owner": {
"username": "jsmith",
"firstname": "Joe",
"lastname": "Smith"
}
},
{
"id": 2,
"type": "Car",
"maxPerson": 5,
}
]
Assuming I know the index of the item. I have tried:
const newOwner = {owner: {username: "jsmith", firstname: "Joe", "lastname": "Smith"};
Cars[index].push(newOwner)
but get:
Cars[index].push is not a function