What is the best aproach using ES6+ sintaxe to go from this:
const mapedTopicsArray = [
['javascript', 'reactjs'],
['Java', 'reactjs'],
]
To this:
const topicsArrayMergedWithoutDuplicates = ['javascript', 'reactjs','Java']
I know that if I use .reduce() I can acomplish that, but I can't figure out how, the nested Array thing is bogging me.
You can easily achieve the result using Set and flat.
const mapedTopicsArray = [
["javascript", "reactjs"],
["Java", "reactjs"],
];
const topicsArrayMergedWithoutDuplicates = [...new Set(mapedTopicsArray.flat())];
console.log(topicsArrayMergedWithoutDuplicates );
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With