I have a javascript array that looks like this:
["polyester", "cotton", "Polyester, Nylon", "Cotton, Acrylic", "Polyester, fiber", "nylon, Leather"]
I would like to mutate this array into this:
["polyester", "cotton", "Nylon", "Acrylic", "fiber", "Leather"]
That is split the strings with commas inside the array and then remove the duplicates while ignoring the case sensitivity. I have looked at other questions on SO. They either explain how to remove duplicates from an array or how to split a single string on commas and not many strings inside an array. I have tried to solve it by:
mutated = a.filter(function(item, pos) {
return a.indexOf(item) == pos;
})
but this does not split the comma seperated strings with in the array. I am seeking for a solution that will do both splitting and removing duplicates while ignoring case sensitivity.