I have an array like this -
"formats": [
{
"format": "eBook",
"published": "3/3/2014",
"id": "1234"
},
{
"format": "Paperback",
"published": "19/3/2020",
"id": "123"
},
{
"format": "eBook",
"published": "19/3/2020",
"id": "12345"
}]
and I would like to write a js filter function that should return me based on the latest format.So something like this
"formats": [
{
"format": "Paperback",
"published": "19/3/2020",
"id": "123"
},
{
"format": "eBook",
"published": "19/3/2020",
"id": "12345"
}]
Where object with id 1234 is removed because another object with the same format (eBook) has a greater published date.
I tried using JS's filter function, but somehow I am messing it up.