Created
September 20, 2018 15:59
-
-
Save spektraldevelopment/48107ada3efc1937639cedc3b12d5956 to your computer and use it in GitHub Desktop.
JS: Capitalize
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 capitalize(str) { | |
const words = []; | |
for (let word of str.split(' ')) { | |
words.push(word[0].toUpperCase() + word.slice(1)); | |
} | |
return words.join(' '); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment