I have and array of arrays aa = [['a'], ['b'], ['c']] and i have an array a = ['a', 'b', 'c'] I need to get the item in aa for each element in a i.e i want to list elements in a with their respective arrays in aa the result should be like a: ['a'] b: ['b'] c: ['c'] I tried this code but it does return the first element i aa for each element in a
I wonder what's wrong here
const aa = [
['a'],
['b'],
['c']
]
const a = ['a', 'b', 'c']
let b = []
a.forEach((el) => {
b.push(
aa.filter((element) => {
return element.includes(el)
})
)
})
console.log(b)