Hack Frontend Community

Capitalize Words in String

AvitoMail.ru
Write a function capitalize(input) that takes a string input and returns its copy, where each word starts with a capital letter.
  • - A "word" is a sequence of Unicode characters from the "letters" group.
  • - Words with hyphens (e.g., "something") are considered one word.

Examples:

Input 1: 'что-то произошло'
Output 1: 'Что-то Произошло'
Input 2: 'foo-bar baz'
Output 2: 'Foo-bar Baz'
Run your code to see results.