first letter of a string uppercase and rest lowercase in javascript code example
Example 1: js first letter to uppercase
function capitalizeFirstLetter(name) {
return name.replace(/^./, name[0].toUpperCase())
}
Example 2: javascript string first letter lowercase
// for lowercase on first letter
let s = "This is my string"
let lowerCaseFirst = s.charAt(0).toLowerCase() + s.slice(1)