Capitalize the First Letter of Each Word

Published by kochug in

Create a method that takes a string as an argument and converts the first character of each word to uppercase. Return the newly formatted string.

Examples

makeTitle("This is a title") ➞ "This Is A Title"

makeTitle("capitalize every word") ➞ "Capitalize Every Word"

makeTitle("I Like Pizza") ➞ "I Like Pizza"

makeTitle("PIZZA PIZZA PIZZA") ➞ "PIZZA PIZZA PIZZA"

Notes

  • You can expect a valid string for each test case.
  • Some words may contain more than one uppercase letter (see example #4).
Watch a quick demo on how Edabit works.