I have two arrays, one representing parents and the other representing children in a relational manner. I need to combine these into a single array.
Parent array:
const cat = ['a','b','c'];
Child array:
const sub =[{name:'cloth',cat:['a','b']},{name:'feshion',cat:['b','a']}]
After combining the two arrays using map and filter methods, the expected output should be:
const parent =[{name:'a',sub:['cloth','feshion']},{name:'b',sub:['cloth','feshion']},{name:'c',sub:[]}]
I've tried using map and filter but it's not working as expected. Can someone please help me with this and provide any ideas?