Created
October 17, 2023 15:37
-
-
Save kevboutin/26f7dc005b04b3d7e691e0d0a36ce3fd to your computer and use it in GitHub Desktop.
Remove duplicates from 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 removeDuplicates = (arr) => [...new Set(arr)]; | |
const arr = [1, 2, 3, 4, 5, 3, 1, 2, 5]; | |
const distinct = removeDuplicates(arr); | |
console.log(distinct); // [1, 2, 3, 4, 5] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment