I've been trying to find a way to remove duplicate items from an Array of Array but can't get my head around it. This is what I'm trying to do.
How do I make a single Array out of this and get rid of duplicates?
let input = [
['Apple', 'Banana'],
['Carrot', 'Peach'],
['Apple', 'Grapes'],
['Mango', 'Cherry'],
['Banana', 'Carrot'],
['Strawberry', 'Apple'],
['Peach', 'BlackBerry'],
['Orange', 'Apple'],
['Banana', 'Grapes']
]
let expectedOutput = ["Apples", "Carrots", "Banana", "Grapes",
"Orange", "Peach", "Cherry", "Strawberry"];
So I found a way to do this by first using: let flattenedArr = input.flat(); followed by: let uniqueArray = [...new Set(flattnedLocationsArry)];