Categories
Capitalizes the first letter of each word in a string.
Contributed by @itsbrunodev
function capitalizeWords(str) { return str.replace(/\b\w/g, (char) => char.toUpperCase()); }
capitalizeWords("hello world"); // "Hello World"