javascript uppercase first character of each word
//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(); });
};function capitalizeFirstLetter(string) {
return string.charAt(0).toUpperCase() + string.slice(1);
}
console.log(capitalizeFirstLetter('foo bar bag')); // Fooconst uppercaseWords = str => str.replace(/^(.)|\s+(.)/g, c => c.toUpperCase());
// Example
uppercaseWords('hello world'); // 'Hello World'
Also in JavaScript:
- remover o primeiro caracter de uma string javascript
- javascript append to json
- how to export switch from react-router-dom
- angular route change scroll to top
- bootstrap show modal jquery
- angular current year
- js promiseStatus
- if json then parse
- react router dom
- nodejs cache data
- js get number of keys in object
- implicit return arrow function
- javascript execute function by string name
- get site url javascript
- javascript count element in array
- react enzyme simulate click sub component
- tensorflow all nodes
- how to convert date to string in javascript
- find match in array object js
- javascript picture delete after time
- ip my adress
- access session data from ejs view
- javascript remove all event listeners
- convert json string to json object in laravel