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