data = [
{
name: "Alpha",
set: 5,
weight: 185
},
{
name: "Alpha",
set: 6,
weight: 350
},
{
name: "Bravo",
set: 2,
weight: 185
},
{
name: "Charlie",
set: 3,
weight: 185
},
{
name: "Echo",
set: 4,
weight: 185
}
]
I have a list of data objects which contain various attributes including the name and weight. My task is to filter this data based on the highest weight for each unique name. For instance, from the two objects with "Alpha", I need to select only the one with the greater weight (the second object). The challenge lies in filtering and reconstructing this data array while retaining the original values.
To facilitate visualizing all the data in a table, I must maintain the initial data array unchanged. However, I also need to create an additional array containing just the objects with the highest weight value for each specified name.