These are the objects and a simple function:
const getTotalYield = plants => {
console.log(plants);
}
const corn = {
name: "corn",
yield: 3,
};
const pumpkin = {
name: "pumpkin",
yield: 4,
};
const crops = [
{ crop: corn, numCrops: 5 },
{ crop: pumpkin, numCrops: 2 },
];
I have to call it like this:
getTotalYield({crops})
output so far:
{
crops: [ { crop: [Object], numCrops: 5 }, { crop: [Object], numCrops: 2 } ]
}
So how do I access the first object and then work with the properties in the array?