Created
March 11, 2020 10:47
-
-
Save susanahernandezd/250081a42d2ac0b9c2ffd386bcb68631 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const array = ['one', 'one', 'two', 'three']; | |
//1. "Set" | |
[...Set(array)] | |
//2. "Filter" | |
array.filter((item, index) => array.indexOf(item) === index) | |
//3. "Reduce" | |
array.reduce((acc, item) => { | |
return acc.includes(item) ? acc : [...acc, item] | |
},[]); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment