I have an array of objects which looks like this:
var array = [
{competitor: "X", fruit: "Cherry", size: 10},
{competitor: "X", fruit: "Banana", size: 20},
{competitor: "Y", fruit: "Cherry", size: 5},
{competitor: "Y", fruit: "Banana", size: 25}
]
How do I get the smallest and unique fruit according to their size regardless of competitor with the result of:
[
{competitor: "X", fruit: "Banana", size: 20},
{competitor: "Y", fruit: "Cherry", size: 5}
]