how to capitalize string in javascript
var str = "Hello World!";
var res = str.toUpperCase(); //HELLO WORLD!//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 lower = 'this is an entirely lowercase string';
const upper = lower.charAt(0).toUpperCase() + lower.substring(1);const name = 'flavio'
const nameCapitalized = name.charAt(0).toUpperCase() + name.slice(1)
Also in JavaScript:
- jsdoc optional param
- how to populate a list in html with javascript
- data-dismiss= modal in jquery
- get object with max value javascript
- how to see if a web site is useing react
- flask javascript not updating
- javascript reduce method stack overflow
- datatables add row
- 'App' is not defined react/jsx-no-undef
- orderbychild firebase react
- React Children map example
- scroll to top in react
- javascript for loops
- axios react post form data
- jquery keyup
- function(global factory)
- vue htmlWebpackPlugin.options.title
- how to use svg in react js
- get image center pixels nodejs
- import checkbox material ui
- js objects
- expose deployment nodeport command
- sort a string in javascript
- javascript math absolute