How can I iterate through object properties and remove duplicates from an array that is the value of that object property?
Original object
var navObjects = {
'Components': ['x', 'y', 'x'],
'Document': ['z', 'z', 'z', 'q'],
'Utilities': ['a', 'b', 'c']
}
Desired object
navObjects: {
'Components': ['x', 'y'],
'Document': ['z','q'],
'Utilities': ['a', 'b', 'c']
}
What I've tried
for (let i = 0; i < Object.values(navObjects).length; i++) {
let obj = Object.values(navObjects)[i];
Object.values(obj).filter((item, index) => obj.indexOf(item) === index);
console.log(obj);
}
The arrays remain unchanged after running this block.