I have a table of data that shows particular product and the amount purchased throughout the day. They were inserted as different objects and I want to add the number of items purchased of each product.
My table look like this
Apple 10 01/20/2021 18:30
Apple 5 01/29/2021 04:30
Apple 20 01/29/2021 07:30
But I want them to be combined into like
Apple 35
So far this is how I set the table
<Table striped="true" size="sm" style={{width: "20%"}}>
<tbody>
{this.state.products?.map((product, index) => (
<tr key={`entity-${index}`}>
<td>{product.type}</td>
<td>{product.amount}</td>
</tr>
))}
</tbody>
</Table>
How can I combine those data based on their type?
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…