capitalizeWords method

String capitalizeWords()

Returns the string with the first character of each word capitalized.

Implementation

String capitalizeWords() {
  if (isEmpty) return this;
  return split(' ').map((word) => word.capitalize()).join(' ');
}