10 examples of 'react capitalize first letter' in JavaScript

Every line of 'react capitalize first letter' 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.

All examples are scanned by Snyk Code

By copying the Snyk Code Snippets you agree to
38export function capitalizeFirstLetter(string: string): string {
39 return string.charAt(0).toUpperCase() + string.slice(1);
40}
5function capitalizeFirstLetter(string) {
6 return string.charAt(0).toUpperCase() + string.slice(1)
7}
3function capitalizeFirstLetter(value) {
4 return value.charAt(0).toUpperCase() + value.slice(1);
5}
4function capitalizeFirst(string) {
5 return string.charAt(0).toUpperCase() + string.slice(1);
6}
23function capitalizeFirstLetter(text) {
24 return text[0].toUpperCase() + text.slice(1);
25}
7export function capitalize (string) {
8 return string && (string.charAt(0).toUpperCase() + string.slice(1))
9}
22function _capitalize(string) {
23 return string && (string.charAt(0).toUpperCase() + string.slice(1));
24}
2function 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}
59export function capitalize(word) {
60 const str = `${word}`;
61 return str.charAt(0).toUpperCase() + str.slice(1);
62}
9function capitalize (word) {
10 var lower = word.toLowerCase();
11 return lower.slice(0, 1).toUpperCase() + lower.slice(1);
12}

Related snippets