Ok, so I have an array of objects that look like that
{id: 1, color: "red", size: "S", free: 14, location: "Location #1"}
{id: 2, color: "green", size: "M", free: 5, location: "Location #1"}
{id: 3, color: "red", size: "M", free: 3, location: "Location #2"}
{id: 4, color: "green", size: "L", free: 12, location: "Location #1"}
{id: 5, color: "green", size: "S", free: 5, location: "Location #2"}
{id: 6, color: "red", size: "L", free: 0, location: "Location #1"}
{id: 7, color: "blue", size: "L", free: 0, location: "Location #2"}
{id: 8, color: "blue", size: "M", free: 0, location: "Location #1"}
{id: 9, color: "blue", size: "S", free: 0, location: "Location #1"}
{id: 10, color: "purple", size: "L", free: 0, location: "Location #2"}
And I want to be able to generate a table that would look something like that
I suppose that i have to filter or group some of the key-value pairs or something like that but i don't know the right way to approach this.
Again maybe for this particular table I have to do something like this:
{
color: 'red',
location: 'Location #1',
sizes: [
{
s: 12
},
{
m: 5
},
{
l: 7
}
]
}
{
color: 'green',
location: 'Location #1',
sizes: [
{
s: 3
},
{
m: 11
},
{
l: 4
}
]
}
But then i have to figure out how to populate the HTML table itself with this data. Maybe there is some library or something that would help me do that. Thanks!

groupBymapping of the array. Then work on iterating that array to create table rows