Preview:
function generateButtons(buttons) {
    // get the dataset value
    let uniqueCategories = [...new Set()];

    buttons.forEach((button) => {
      const category = button.dataset.category;
      uniqueCategories.push(category);
    });

    uniqueCategories = uniqueCategories.filter(function (item, pos) {
      return uniqueCategories.indexOf(item) == pos;
    });

    uniqueCategories.unshift("All");

    console.log(uniqueCategories);

    // return ` <button type="button" class="filter-btn" data-id="${category}">${category}</button>`;
  }
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