Filter and Summarize
Category Options
Build a Filter List
A browser table derives unique category names from CSV records so a filter select can show one option per category.
Program
CSV rows often repeat values. The browser can derive a short option list from those repeated values without changing the source records.
category_options.html
<script>
const records = [
{ item: "Tea", category: "pantry" },
{ item: "Tape", category: "office" },
{ item: "Rice", category: "pantry" }
];
const categories = records.map(row => row.category);
const unique = [...new Set(categories)];
renderSelect(unique);
</script>
map
map creates a new array by reading one value from each row.
Set
A Set keeps one copy of each value, which is useful for filter options.