I have a product in multiple variations
{
product: {
name: 'TShirt',
brand: 'Some brand",
variations: [
{
color: 'red',
sku: '1234',
price: 129,
id: 1
},
{
color: 'black',
sku: '123442',
price: 99,
id: 2,
},
{
color: 'yellow',
sku: '1234423',
price: 79,
id: 3
}
]
}
}
Now I want to get and display the cheapest variation of the product. I've managed to get the cheapest variants price:
const min = Math.min(...variations.map((item) => item.price))
but how can I get the rest of the object? In this example the 'yellow' variant?
Juan Pablo Isaza