captitalize js
//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 lower = 'this is an entirely lowercase string';
const upper = lower.charAt(0).toUpperCase() + lower.substring(1);function capitalize2(str) {
str = str.toLowerCase();
const arrOfWords = str.split(" ");
const arrOfWordsCased = [];
for (let i = 0; i < arrOfWords.length; i++) {
const char = arrOfWords[i].split("");
char[0] = char[0].toUpperCase();
res.push(char.join(""));
}
return arrOfWordsCased.join(" ");
}
Also in JavaScript:
- json opposite of stringify
- javascript remove element
- Javascript generator example
- change image src jquery
- child process spawn python node js
- getting value from radio button javascript
- react native length of object
- how to get whole json object with jsonpath
- scrollbar position
- detect browser javascript
- javascript render jsx element x many times
- react Spread Attributes conditionally
- hide url in discord.js
- javascript not empty array not string
- js add class
- string contains string javascript
- check if object is present in array javascript
- json data example
- jquery datepicker no past dates
- settimeout in angular
- simple express server
- js array contains
- how to delete everything from a folder in js
- web worker multiple data