//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(); });
};
const names = ["alice", "bob", "charlie", "danielle"]
// --> ["Alice", "Bob", "Charlie", "Danielle"]
//Just use some anonymous function and iterate through each of the elements in the array
//and take string as another array
let namescap = names.map((x)=>{
return x[0].toUpperCase()+x.slice(1)
})
console.log(namescap)
// this will only capitalize the first word
var name = prompt("What is your name");
firstLetterUpper = name.slice(0,1).toUpperCase();
alert("Hello " + firstLetterUpper + name.slice(1, name.length).toLowerCase());
var name = prompt("What is your name");
firstLetterUpper = name.slice(0,1).toUpperCase();
alert("Hello " + firstLetterUpper + name.slice(1, name.length).toLowerCase());
// name er first letter uppercase
let name = "aminul islam rasel" //Aminul Islam Rasel
let word = name.split(" ") // create array each word
word[0] = word[0].charAt(0).toUpperCase() + word[0].slice(1)
word[1] = word[1].charAt(0).toUpperCase() + word[1].slice(1)
word[2] = word[2].charAt(0).toUpperCase() + word[2].slice(1)
name = word.join(" ")// get Aminul Islam Rasel
console.log(name);//show console
// array map method use kore
let name = "abdur razzak hassan tusher mafus ulla"
let word = name.split(" ")
word = word.map(function (value) {
return value.charAt(0).toUpperCase() + value.slice(1)
})
name = word.join(" ")
console.log(name);
public static void main(String[] args)
{
System.out.println("Enter name");
Scanner kb = new Scanner (System.in);
String text = kb.next();
if ( null == text || text.isEmpty())
{
System.out.println("Text empty");
}
else if (text.charAt(0) == (text.toUpperCase().charAt(0)))
{
System.out.println("First letter in word "+ text + " is upper case");
}
}