Created
April 8, 2016 10:08
-
-
Save louy2/fc63889bac8715c8238d6305d4cc2824 to your computer and use it in GitHub Desktop.
Titlecase string in JavaScript with RegExp https://www.freecodecamp.com/challenges/title-case-a-sentence
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 titleCase(str) { | |
return str.toLowerCase().replace(/(^[a-z]| [a-z])/g, function(match) { | |
return match.toUpperCase(); | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment