Skip to content

Instantly share code, notes, and snippets.

@phatnguyenuit
Created September 18, 2019 03:12
Show Gist options
  • Save phatnguyenuit/6d34bbc679c14d6dded9fd0c259c68d8 to your computer and use it in GitHub Desktop.
Save phatnguyenuit/6d34bbc679c14d6dded9fd0c259c68d8 to your computer and use it in GitHub Desktop.
Recursively remove all adjacent duplicates
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