capitalize the first word in js code example
Example 1: javascript capitalize first letter
const lower = 'this is an entirely lowercase string';
const upper = lower.charAt(0).toUpperCase() + lower.substring(1);
Example 2: capitalize first letter in each word javascript
search function
<ion-input [(ngModel)]="keyword" (ngModelChange)="toTitleCase($event)" class="input-container" placeholder="Enter Input"></ion-input>
function capital_letter(str)
{
str = str.split(" ");
for (var i = 0, x = str.length; i < x; i++) {
str[i] = str[i][0].toUpperCase() + str[i].substr(1);
}
return str.join(" ");
}
console.log(capital_letter("Write a JavaScript program to capitalize the first letter of each word of a given string."));