Write a function capitalizeWords(text) that returns a copy of the string text in which every word starts with a capital letter: 'hello world' becomes 'Hello World'.
' ' only: a tab or a line break is part of a word, not a separator.toUpperCase(). If it is a digit or a sign, it stays the same: '3d model' becomes '3d Model'.'hello wORLD' becomes 'Hello WORLD'. An apostrophe does not start a new word: "don't" becomes "Don't".'élan' becomes 'Élan'.''.You can walk over the characters, or split the string on spaces and join the words back. Either way, two spaces in a row are still two spaces in the result (whitespace is not removed).
capitalizeWords('hello world')Returns 'Hello World'
capitalizeWords('hello wORLD')Returns 'Hello WORLD'
capitalizeWords(' two spaces ')Returns ' Two Spaces '
Asked at T-Bank · Source
capitalizeWords('hello world')'Hello World'capitalizeWords('hello wORLD')'Hello WORLD'capitalizeWords('')''Hidden tests run on Submit.