I have an array of objects:
const workouts = [
  {
    id: 1,
    name: "Bench Press",
    superset_id: 1,
  },
  {
    id: 2,
    name: "Squats",
    superset_id: 2,
  },
  {
    id: 3,
    name: "Shoulder Press",
    superset_id: 1,
  },
  {
    id: 4,
    name: "Leg Press",
    superset_id: 2,
  },
  ...
];
What I would like to do is filter the array for objects with a matching superset_id and return a new array that looks like this:
[
  [
    {
      id: 1,
      name: "Bench Press",
      superset_id: 1,
    },
    {
      id: 3,
      name: "Shoulder Press",
      superset_id: 1,
    },
  ],
  [
    {
      id: 2,
      name: "Squats",
      superset_id: 2,
    },
    {
      id: 4,
      name: "Leg Press",
      superset_id: 2,
    },
  ],
    ...
];
How can I achieve this?
 
     
     
     
    