Last active
February 12, 2020 00:52
-
-
Save james-fourth/ef4f1300d652a53b91864406bdbe7321 to your computer and use it in GitHub Desktop.
Remove duplicates from a string
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 dedupe = (string) => { | |
const parsed = string.split('') | |
let deduplicate = []; | |
parsed.map(function(value) { | |
if (!deduplicate.includes(value)) { | |
deduplicate.push(value); | |
} | |
}) | |
return deduplicate.join(''); | |
} | |
export default dedupe; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment