Created
August 17, 2018 18:03
-
-
Save akhilome/45b7009059fa8d6fb4506e107aeb75fc to your computer and use it in GitHub Desktop.
Recursively remove punctuation from end of words in Javascript
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
function stripWords(word) { | |
if(/[a-z]/.test(word[word.length - 1])) { | |
return word; | |
} else { | |
return stripWords(word.substring(0, word.length - 1)); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment