I would like to display the value 122 of amount but I don't know how to do that.
I have this value
const products = [
{
id: 1,
productM: [
{
product: {
productId: 1222,
price: {
currency: 'EUR',
amount: 122,
},
},
},
],
label: 'corner-1',
sourceId: 23333,
},
]
I tried this function but it's not working and I don't know how to do that
function getTotalPrice(products) {
const arr = products.map((product) =>
product.productM.map((p) => p.price.amount)
);
return arr.reduce(
(accumulator, product) => accumulator + product,
0
);
}
If anyone can help, many thanks
product.productMdo not have apriceproperty. They only have aproductproperty.