I have the following array:
[
["Polymeric", "Vehicle Graphics (Basic)"],
["Cast", "Vehicle Graphics (Part Wrap), Vehicle Graphics (Full Wrap)"],
["Polymeric", "Vehicle Graphics (Part Wrap)"]
]
You'll notice that the 2nd lines of the array's second value has a value separated by a comma. I want to recreate the array like so.
[
["Polymeric", "Vehicle Graphics (Basic)"],
["Cast", "Vehicle Graphics (Part Wrap)"],
["Cast", "Vehicle Graphics (Full Wrap)"],
["Polymeric", "Vehicle Graphics (Part Wrap)"]
]
Here's what I have so far:
const media = [
["Polymeric", "Vehicle Graphics (Basic)"],
["Cast", "Vehicle Graphics (Part Wrap), Vehicle Graphics (Full Wrap)"],
["Polymeric", "Vehicle Graphics (Part Wrap)"]
];
var filteredArray = media.filter(function(r) {return r[1]})
filteredArray.forEach(function(value) {
var fgh = value.slice(1);
var cddd = [value.shift()]; // takes first part
var ttt = fgh.toString()
var str_array = ttt.split(', ');
const array3 = cddd.concat(fgh);
console.log(str_array);
});
I understand I need to use concat, split and then finally push it back but whatever I try I'm not getting the result I need so I need help and now I'm lost?
