Created
September 18, 2019 03:12
-
-
Save phatnguyenuit/6d34bbc679c14d6dded9fd0c259c68d8 to your computer and use it in GitHub Desktop.
Recursively remove all adjacent duplicates
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
function remove_adjacent_duplicates(str) { | |
return str.replace(/(\w)\1+/g, ''); | |
} | |
remove_adjacent_duplicates("geeksforgeek") //gksforgk |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment