Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

capitalize first letter javascript

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

console.log(capitalizeFirstLetter('foo bar bag')); // Foo
Comment

javascript capitalize first letter

const lower = 'this is an entirely lowercase string';
const upper = lower.charAt(0).toUpperCase() + lower.substring(1);
Comment

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)
Comment

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());
Comment

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);
Comment

Javascript Capitalize First Letter

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

console.log(capitalizeFirstLetter('foo')); // Foo
 Run code snippet
Comment

Capitalize the first letter of string using JavaScript

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

make the first letter of a string upper case

>>> "hello world".title()
'Hello World'
>>> u"hello world".title()
u'Hello World'
Comment

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(" ");
Comment

javascript capitalize first letter

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

Comment

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"
Comment

first name capital letter


function firstCapitalLetter(name){
    return name[0].slice('').toUpperCase() + name.slice(1).toLowerCase()
}


 console.log(firstCapitalLetter('front '))
Comment

JavaScript Capitalize First Letter

 const capitalize = ([first, ...rest]) => first.toUpperCase() + rest.join("").toLowerCase(); 
Comment

capitalize first letter of a string

const name = 'flavio'
const nameCapitalized = name.charAt(0).toUpperCase() + name.slice(1)
Comment

Capitalize first letter

String name;

BufferedReader br = new InputStreamReader(System.in);

String s1 = name.charAt(0).toUppercase());

System.out.println(s1 + name.substring(1));
Comment

first Letter as Capital

string.charAt(index)
Comment

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();
    }
Comment

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");
     }
  }
Comment

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
Comment

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(" ");
Comment

PREVIOUS NEXT
Code Example
Javascript :: remove duplicated from array 
Javascript :: how to global a variable in javascript 
Javascript :: deparam javascript 
Javascript :: angular pipe paramerte 
Javascript :: using connect flash 
Javascript :: empty the integer array javascript 
Javascript :: extends in js 
Javascript :: why sort is not working in javascript 
Javascript :: react navigation 
Javascript :: angular directive to trim input 
Javascript :: how to find dates in a string in js 
Javascript :: opposite of includes javascript 
Javascript :: function expression javascript 
Javascript :: example of call by value and call by reference in javascript 
Javascript :: node js arabic number to english number 
Javascript :: get row data in datatable 
Javascript :: how to combine two regular expressions in javascript 
Javascript :: unexpected token w in json at position 0 
Javascript :: regex javascript online 
Javascript :: define methods of objects in javascript 
Javascript :: Array iteration in ES6 
Javascript :: nest js crons 
Javascript :: regular expression for beginners javascript 
Javascript :: js string insert space 
Javascript :: how to change object property value in javascript 
Javascript :: delete request reaxt 
Javascript :: javascript addeventlistener click multiple elements 
Javascript :: array reduce 
Javascript :: mail testing 
Javascript :: how to upload react js project on server 
ADD CONTENT
Topic
Content
Source link
Name
4+9 =