Created
December 24, 2014 06:39
-
-
Save angrytoast/0df57176fa1b4fa89449 to your computer and use it in GitHub Desktop.
JS string transform for english possessive
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(input) { | |
| if(typeof input === 'string') { | |
| input = input.trim(); | |
| input = (input.toLowerCase().slice(-1) === 's') ? input + "'" : input + "'s"; | |
| } | |
| return input; | |
| }; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment