Preview:
const groupData = (array, key) => {
      return array.reduce((acc, curr) => {
        const group = curr[key];
        if (!acc[group]) {
          acc[group] = [];
        }
        acc[group].push(curr);
        return acc;
      });
    };
    const groupedData = groupData(galleryData, "building");
downloadDownload PNG downloadDownload JPEG downloadDownload SVG

Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!

Click to optimize width for Twitter