Dev Helpers
← Back

List tags exclusive to one entry

List tags exclusive to one entry. Inspect the transformed data in the console.

Open this example in the interactive library

Source code

const rows = [
  { title: "Tide", tags: ["sea", "blue"] },
  { title: "Dune", tags: ["sand", "gold"] },
  { title: "Reef", tags: ["sea", "gold"] },
  { title: "Blank", tags: [] },
];
const result = [...new Set(rows.flatMap((r) => r.tags))].filter(
  (t) => rows.filter((r) => r.tags.includes(t)).length === 1,
);
console.log(JSON.stringify(result, null, 2));

Sample output

[
  "blue",
  "sand"
]