xxxxxxxxxx
>>> "hello world".title()
'Hello World'
>>> u"hello world".title()
u'Hello World'
xxxxxxxxxx
function capFirst(str) {
return str[0].toUpperCase() + str.slice(1);
}
console.log(capFirst('hello'));
//output
//Hello
xxxxxxxxxx
const string = "tHIS STRING'S CAPITALISATION WILL BE FIXED."
const string = string[0].toUpperCase() + string.slice(1)
xxxxxxxxxx
function capitalizeFirstLetter(str) {
return str.charAt(0).toUpperCase() + str.slice(1);
}
// Example usage
const myString = "hello world";
const capitalizedString = capitalizeFirstLetter(myString);
console.log(capitalizedString); // Output: "Hello world"
xxxxxxxxxx
function capitalizeFirstLetter(str) {
return str.charAt(0).toUpperCase() + str.slice(1);
}
// Example usage
const text = "hello world";
const capitalizedText = capitalizeFirstLetter(text);
console.log(capitalizedText); // Output: "Hello world"
xxxxxxxxxx
function capitalizeFirstLetter(name) {
return name.replace(/^./, name[0].toUpperCase())
}
xxxxxxxxxx
const lower = 'this is an entirely lowercase string';
const upper = lower.charAt(0).toUpperCase() + lower.substring(1);
xxxxxxxxxx
var name = prompt("What is your name");
firstLetterUpper = name.slice(0,1).toUpperCase();
alert("Hello " + firstLetterUpper + name.slice(1, name.length).toLowerCase());
xxxxxxxxxx
const name = 'flavio'
const nameCapitalized = name.charAt(0).toUpperCase() + name.slice(1)
xxxxxxxxxx
var str = "hello world";
str = str.toLowerCase().replace(/\b[a-z]/g, function(letter) {
return letter.toUpperCase();
});
alert(str); //Displays "Hello World"