Every line of 'javascript capitalize all letters' code snippets is scanned for vulnerabilities by our powerful machine learning engine that combs millions of open source libraries, ensuring your JavaScript code is secure.
145 function capitalize(string) { 146 return string.replace(/^[a-z]/, function(str) { 147 return str.toUpperCase(); 148 }); 149 }
38 export function capitalizeFirstLetter(string: string): string { 39 return string.charAt(0).toUpperCase() + string.slice(1); 40 }
5 function capitalizeFirstLetter(string) { 6 return string.charAt(0).toUpperCase() + string.slice(1) 7 }
2 function LetterCapitalize (str) { 3 // First, we use the split method to divide the input string into an array of individual words 4 // Note that we pass a string consisting of a single space into the method to "split" the string at each space 5 str = str.split(' '); 6 7 // Next, we loop through each item in our new array... 8 for (var i = 0; i < str.length; i++) { 9 // ...and set each word in the array to be equal to the first letter of the word (str[i][0]) capitalized using the toUpperCase method. 10 // along with a substring of the remainder of the word (passing only 1 arg into the substr method means that you start at that index and go until the end of the string) 11 str[i] = str[i][0].toUpperCase() + str[i].substr(1); 12 } 13 // Finally, we join our array back together... 14 str = str.join(' '); 15 16 // ...and return our answer. 17 return str; 18 }
4 function capitalizeString(string: string): string { 5 return string.charAt(0).toUpperCase() + string.slice(1) 6 }
7 export function capitalize (string) { 8 return string && (string.charAt(0).toUpperCase() + string.slice(1)) 9 }
22 function _capitalize(string) { 23 return string && (string.charAt(0).toUpperCase() + string.slice(1)); 24 }
3 function capitalize (string) { 4 return string.charAt(0).toUpperCase() + string.substr(1).toLowerCase() 5 }
7 function capitalize(str) { 8 return str && str[0].toUpperCase() + str.slice(1); 9 }
3 function capitalize(string) { 4 return string.charAt(0).toUpperCase() + string.slice(1); 5 }