Answers for "first letter capital in javascript"

95

js first letter uppercase

//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(); });
};
Posted by: Guest on July-22-2019
31

javascript capitalize first letter

const lower = 'this is an entirely lowercase string';
const upper = lower.charAt(0).toUpperCase() + lower.substring(1);
Posted by: Guest on March-04-2020
6

capitalize in javascript

const name = 'flavio'
const nameCapitalized = name.charAt(0).toUpperCase() + name.slice(1)
Posted by: Guest on August-13-2020
2

first letter tuUppercase

const string = "tHIS STRING'S CAPITALISATION WILL BE FIXED."
const string = string[0].toUpperCase() + string.slice(1)
Posted by: Guest on October-15-2020
4

capitalise first letter js

const string = "tHIS STRING'S CAPITALISATION WILL BE FIXED."
const string = string.charAt(0).toUpperCase() + string.slice(1)
Posted by: Guest on September-03-2020
0

first letter capital in javascript

function capitalizeFirstLetter(string) {
  return string.charAt(0).toUpperCase() + string.slice(1);
}

console.log(capitalizeFirstLetter('foo')); // Foo
Posted by: Guest on August-31-2020

Code answers related to "first letter capital in javascript"

Code answers related to "Javascript"

Browse Popular Code Answers by Language