How to Capitalize the First Letter of Each Word in React

added by JavaScript Kicks
12/5/2022 2:42:12 PM

1554 Views

To capitalize the first letter of each word in a string in React: Split the string into an array of words with .split(''). Iterate over the words array with .map(). For each word, return a new word that is an uppercase form of the word's first letter added to the rest of the word, i.e., word.charAt(0).toUpperCase() + word.slice(1).


0 comments