TIL a helper to make things uppercase
POSTED ON:
TAGS: javascript helper string
Needed a helper function to make things uppercase?
ucWords
ucWords function converts the first character of each word in a string to uppercase. This function is the same as PHP’s ucWords function.
export const ucWords = string => {
return String(string).toLowerCase()
.replace(/\b[a-z]/g, (l) => l.toUpperCase())
}
via JavaScript String Helpers That I Use Every Day
Related TILs
Tagged: javascript