Files
30-seconds-of-code/snippets/capitalize-first-letter-of-every-word.md
Angelos Chalaris c83394b44a Build README
2017-12-12 15:38:34 +02:00

236 B

Capitalize first letter of every word

Use replace() to match the first character of each word and toUpperCase() to capitalize it.

var capitalizeEveryWord = str => str.replace(/\b[a-z]/g, char => char.toUpperCase());