I have an array of arrays which I want to marge into one and remove duplicate values.
let arr = [ {
label :'XYZ',
colors:['black','white','blue']
},
{
label :'PQR',
colors:['orange','yellow','white']
},
{
label :'ABC',
colors:['black','pink','blue']
},
]
let updatedArr = []
for(let i=0 i< arr.length ; i++ ){
updatedArr.push(
arr[i].reduce((a, b) => [...a, ...b], [])
)
}
I want all the colors array value into one array and remove duplicate values as well.
Any help would be great.