I am trying to do a forEach loop and take each item and split it at a character. In this case I want to split the array item text at "||". What I currently have is:
var array = [
[
"featured", ["feat||1", "feat||2", "feat||3"]
],
[
"new", ["new||1", "new||2", "new||3"]
]
];
var taxIDs = [];
array.forEach((i) => {
if (i[1].length) {
taxIDs.push(i[1].split("||")[1]);
}
});
So I was trying to take i[1] and splitting it at "||" and getting the second item in that split array, but doing this throws and error and not sure the best approach to accomplish what I need?
EDIT (this is what I see when console logging my array:
(3) [Array(2), Array(2)]
0: (2) ["featured", Array(3)]
0: "featured"
1: (3) ["feat||1", "feat||2", "feat||3"]
1: (2) ["news", Array(2)]
0: "news"
1: (2) ["news||1", "news||2", "news||3"]
So there are 3 levels of arrays in this array.