Created
June 16, 2016 14:02
-
-
Save devlemire/f8fb7f056fa6633f94ca60e9faa6e9bf 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
//make a function that takes in a string and capatalizes the first letter of every word and lowercase the rest | |
function capFirstLetter(str) { | |
str = str.toLowerCase().split(' '); | |
for(var i in str) { | |
str[i] = str[i].split(''); | |
} | |
for(var j in str) { | |
var holder = str[j][0].charAt(0).toUpperCase(); | |
str[j][0] = holder; | |
str[j] = str[j].join(''); | |
} | |
str = str.join(' '); | |
console.log(str); | |
} | |
capFirstLetter("one two three"); |
Author
devlemire
commented
Jun 29, 2018
•
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment