Created
July 21, 2020 10:36
-
-
Save keithn/570216bcdf10142ac16bfe785c07c6b1 to your computer and use it in GitHub Desktop.
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) { | |
let titled = [] | |
let upper = true; | |
for(let letter of str.toLowerCase()) { | |
titled.push( upper ? letter.toUpperCase() : letter ) | |
upper = (letter === ' ') | |
} | |
return titled.join('') | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment