javascript capitalize words
//Updated
//capitalize only the first letter of the string.
function capitalizeFirstLetter(string) {
return string.charAt(0).toUpperCase() + string.slice(1);
}
//capitalize all words of a string.
function capitalizeWords(string) {
return string.replace(/(?:^|\s)\S/g, function(a) { return a.toUpperCase(); });
};//capitalize only the first letter of the string.
function capitalizeFirstLetter(string) {
return string.charAt(0).toUpperCase() + string.slice(1);
}
//capitalize all words of a string.
function capitalizeWords(string) {
return string.replace(/(?:^|\s)\S/g, function(a) { return a.toUpperCase(); });
};myString = 'the quick green alligator...';
myString.replace(/^\w/, (c) => c.toUpperCase());
myString = ' the quick green alligator...';
myString.trim().replace(/^\w/, (c) => c.toUpperCase());
Also in JavaScript:
- run command line using javascript
- how to make a css clock
- rngesturehandlermodule.default.direction react native
- vue js error mixed spaces and tabs no-mixed-spaces-and-tabs
- global site tag (gtag.js) - google analytics gatsby
- Angularjs datetime
- biden trump javascript real time election
- conditional chaining chrome
- last element of an array javascript
- javascript check if is object
- sort javascript array
- push javascript
- javascript array column
- cascading dropdown for forms react
- javascript merge two array with spread operator
- javascript dir
- how to write statefull class in react
- timestamp to unix time react
- get url react
- single node elasticsearch with enable security basic in docker
- node.js read text file line by line
- how to deploy react app firebase
- javascript constructor function
- object.keys javascript stack overflow