I have an array of objects where each object contains a category, and if there are any duplicate categories, I need to only display one object for each unique category.
Below is the array:
const costItems= [
{
amount: 1000,
category: 'Appliances',
instructions: '',
subcontractor: [Object],
thresholdAmount: null,
thresholdPercent: null
},
{
amount: 500,
category: 'Appliances',
instructions: '',
subcontractor: [Object],
thresholdAmount: null,
thresholdPercent: null
},
{
amount: null,
category: 'Appraisal',
instructions: '',
subcontractor: [Object],
thresholdAmount: null,
thresholdPercent: null
},
{
amount: null,
category: 'Building Permit',
instructions: '',
subcontractor: [Object],
thresholdAmount: null,
thresholdPercent: null
}
]
Is there a way to remove duplicate categories from this array of objects?