DekGenius.com
JAVASCRIPT
javascript separate words by capital letter
"thisIsATrickyOne".split(/(?=[A-Z])/);
uppercase in word javascript
function toTitleCase(str) {
return str.replace(/wS*/g, function(txt){
return txt.charAt(0).toUpperCase() + txt.substr(1).toLowerCase();
});
}
javascript Capitalise a String
const capitalize = str => str.charAt(0).toUpperCase() + str.slice(1)
capitalize("follow for more")
// Result: Follow for more
javascript capitalize words
//Updated
//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(); });
};
javaSript string first words to upper case
function titleCase(str) {
return str.toLowerCase().replace(/(^|s)S/g, L => L.toUpperCase());
}
find capital word in string javascript
const str = "HERE'S AN UPPERCASE PART of the string";
const upperCaseWords = str.match(/([A-Z][A-Z]+|[A-Z])/g);
console.log(upperCaseWords);
js capitalize word
const capitalizeFirstLetter(string) =>
string.charAt(0).toUpperCase() + string.slice(1).toLowerCase()
capitalize a string javascript
const Capitalize = function(string){
return string[0].toUpperCase + string.slice(1).toLowerCase;
}
How to capitalize the first letter of a word in JavaScript
const word = "freecodecamp"
const capitalized =
word.charAt(0).toUpperCase()
+ word.slice(1)
// Freecodecamp
// F is capitalized
javascript capitalize all letters
function capitalizeWords(string) {
return string.replace(/(?:^|s)S/g, function(a) { return a.toUpperCase(); });
};
javascript capitalize all words
export function capitalize(str: string, all: boolean = false) {
if (all)
return str.split(' ').map(s => capitalize(s)).join(' ');
return str.charAt(0).toUpperCase() + str.slice(1);
}
© 2022 Copyright:
DekGenius.com