Created
November 20, 2018 18:23
-
-
Save alex-cory/727caa3e0a6d36fb880dc1afa2333cef to your computer and use it in GitHub Desktop.
Capitalizes strings
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
/** | |
* Handles special characters too | |
*/ | |
const capitalize = w => w.toLowerCase().replace(/(?:^|\s)\S/g, l => l.toUpperCase()); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment