DISCLAIMER: Please dont mind my stupid object names, its just to learn the basics
I have an array of objects named "cars":
const cars = [
{
name: "red",
competes: true,
category: 2,
given: 400
},
{
name: "blue",
competes: false,
category: 2,
given: 0
},
{
name: "green",
competes: true,
category: 2,
given: 0
}
]
And another array of objects named addOns:
const addOns = [
{
name: "hyperblast",
upgrade: 100
},
{
name: "catalyst",
upgrade: 400
}
]
Question
How can i add for example the addOn {name: "catalyst", upgrade: 400} to the car named "green"?
Ive tried with
cars[2].push(addOns[1]);
but it doesnt work. And all my google searches were without result (arrays of objects seem so important but I constantly fail to find anything regarding. Only about arrays or objects, never together)