I have this returned group of arrays returned as in, which is output console logging an array named forTypes:
["milk", "bread"]
["milk"]
["bread"]
["cheese", "jam"]
I have been trying to filter its out using
let forTypesUnique = [...new Set(forTypes)];
I have also tried using other functions such as Reduce() but no luck!
Should I combine those separate arrays into one and then filter out? Any suggestions would be appreciated.
flattento flatten the nested arrays into a single array of values, which you can then pass to your Set constructor to de-dupe. If this is some learning exercise where you cannot use libraries, then try looping through the array, then checking if the value you have is also an array, and looping through it...in your loop add items to the set one by one.forTypesis array of arrays?