DekGenius.com
JAVASCRIPT
capitalize first letter javascript
function capitalizeFirstLetter(string) {
return string.charAt(0).toUpperCase() + string.slice(1);
}
console.log(capitalizeFirstLetter('foo bar bag')); // Foo
javascript capitalize first letter
const lower = 'this is an entirely lowercase string';
const upper = lower.charAt(0).toUpperCase() + lower.substring(1);
make first letter capital
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)
js capitalize first letter
// 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());
capitalize first letter of string javascript
let val = ' this is test ';
val = val.trim();
val = val.charAt(0).toUpperCase() + val.slice(1);
console.log("Value => ", val);
Javascript Capitalize First Letter
function capitalizeFirstLetter(string) {
return string.charAt(0).toUpperCase() + string.slice(1);
}
console.log(capitalizeFirstLetter('foo')); // Foo
Run code snippet
Capitalize the first letter of string using JavaScript
function capitalizeFirstLetter(string) {
return string.charAt(0).toUpperCase() + string.slice(1);
}
make the first letter of a string upper case
>>> "hello world".title()
'Hello World'
>>> u"hello world".title()
u'Hello World'
Return the provided string with the first letter of each word capitalized
const mySentence = "freeCodeCamp is an awesome resource";
const words = mySentence.split(" ");
for (let i = 0; i < words.length; i++) {
words[i] = words[i][0].toUpperCase() + words[i].substr(1);
}
words.join(" ");
javascript capitalize first letter
function capitalizeFirstLetter(string) {
return string.charAt(0).toUpperCase() + string.slice(1);
}
Uppercase first letter of variable
var str = "hello world";
str = str.toLowerCase().replace(/[a-z]/g, function(letter) {
return letter.toUpperCase();
});
alert(str); //Displays "Hello World"
first name capital letter
function firstCapitalLetter(name){
return name[0].slice('').toUpperCase() + name.slice(1).toLowerCase()
}
console.log(firstCapitalLetter('front '))
JavaScript Capitalize First Letter
const capitalize = ([first, ...rest]) => first.toUpperCase() + rest.join("").toLowerCase();
capitalize first letter of a string
const name = 'flavio'
const nameCapitalized = name.charAt(0).toUpperCase() + name.slice(1)
Capitalize first letter
String name;
BufferedReader br = new InputStreamReader(System.in);
String s1 = name.charAt(0).toUppercase());
System.out.println(s1 + name.substring(1));
first Letter as Capital
how to capitalize the first character in array of string
for(var i = 1 ; i < newArr.length ; i++){
newArr[i] = newArr[i].charAt(0).toUpperCase();
}
first letter of string is capital
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");
}
}
Capitalize first letter of each word
const toTitleCase = str => str.replace(/(^w|sw)(S*)/g, (_,m1,m2) => m1.toUpperCase()+m2.toLowerCase())
console.log(toTitleCase("heLLo worLd"));
// Hello World
Capitalize the first letter of each word
const mySentence = "freeCodeCamp is an awesome resource";
const words = mySentence.split(" ");
words.map((word) => {
return word[0].toUpperCase() + word.substring(1);
}).join(" ");
© 2022 Copyright:
DekGenius.com