I have this array with several different products, could be up to 100 different products. I could have same product with different prices and different products. I need to get the highest price on each batch.
This is a sample array
arrayOfProducts = [
{
product: {
batch: 11201,
price: 745
}
},
{
product: {
batch: 11201,
price: 746
}
},
{
product: {
batch: 11201,
price: 747
}
},
{
product: {
batch: 11202,
price: 748
}
},
{
product: {
batch: 11202,
price: 749
}
},
{
product: {
batch: 11202,
price: 750
}
}
]
And this is what I want to see as a result after filtering through it
filteredArrayOfProducts = [
{
product: {
batch: 11201,
price: 747
}
},
{
product: {
batch: 11202,
price: 750
}
}
]