This has been posted time and time again and after reading them all, I still don't know what I'm doing wrong. I understand there are so many ways to do this and I get the feeling I've mixed them up.
I'm trying to get the uniques value from serviceType so rather than having Cars Now, Cars Now, Vans Now, I should only have Cars No, Vans Now.
See attached code
const preFilteredRows = [
{
"serviceType": "Cars Now",
"applictionType": "Direct",
"wheelType": "4x4"
},
{
"serviceType": "Cars Now",
"applictionType": "web",
"wheelType": "2x4"
},
,
{
"serviceType": "Vans Now",
"applictionType": "Direct",
"wheelType": "2x4"
}
]
let tempArr = [];
preFilteredRows.forEach(row => {
if(row.values[serviceType].length == 1) tempArr.push(row.values[serviceType][0])
})
/* return [...new Set(tempArr)] */
newServiceSet = [...new Set(tempArr)]
console.log(newServiceSet)
UPDATE: Thank you all so much for your feedback, I really do appreciate your help with my learning.
One part I forgot to add to my question and just realise is, I not only need the uniques values, but I also need them displayed like the below image so each value has a value and a label. I don't need the count anymore.

.valuesyour if statement checks forforEach(); I think thatrow.values[serviceType].length == 1should berow.serviceType.length > 0; but honestly I don't really know (as I said) what you're testing for (and this is why comments are good things).