Answers for "javascript string alphabetical order uppercase lowercase"

98

javascript capitalize words

//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
0

lowercase or uppercase all strings in array javascript

const names = ['Ali', 'Atta', 'Alex', 'John'];

const lowercased = names.map(name => name.toLowerCase());

console.log(lowercased);
// ['ali', 'atta', 'alex', 'john']

const uppercased = names.map(name => name.toUpperCase());

console.log(uppercased);
// ['ALI', 'ATTA', 'ALEX', 'JOHN']
Posted by: Guest on October-27-2021

Code answers related to "javascript string alphabetical order uppercase lowercase"

Code answers related to "Javascript"

Browse Popular Code Answers by Language