Created
December 25, 2017 20:51
-
-
Save davidicus/3fbdbd3f32c520a9cae01918c617660d to your computer and use it in GitHub Desktop.
Remove duplicate values in an array
This file contains hidden or 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 myArray = [0, 1, 1, 2, 3, 3] | |
myArray.reduce((a, b) => { | |
if (a.indexOf(b) < 0) { | |
a.push(b); | |
} | |
return a; | |
}, []); | |
// returns [0,1,2,3] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment