I have an array that is combining the sources of multiple arrays using concat
.
var tags = [].concat.apply([], [typeArr,genderArr,conditionArr]);
The items in the array are then filtered for any
tags = tags.filter(function(entry) { return entry.trim() != ''; });
However, I realized that, because of where the data comes from, some items are coming in as strings with commas, such that tags
array looks like the following: ["red","blue","green,yellow,orange","purple,black"]
How could I split the items so that the tags array looks like ["red","blue","green","yellow","orange","purple","black"]
? I was thinking something where I loop over the array and then use split to reinsert these into a new array?
I'm trying to do it with vanilla JavaScript