Capitalize the Title
Words in title are separated by single spaces. Change each word like this:
- If it has 1 or 2 letters, make every letter lowercase.
- Otherwise make the first letter uppercase and the rest lowercase.
Return the new title.
Example 1
title "capiTalIze tHe titLe"
returns "Capitalize The Title"
Each word is longer than 2 letters, so each becomes Capitalize The Title.
Example 2
title "First leTTeR of EACH Word"
returns "First Letter of Each Word"
Constraints
1 <= len(title) <= 100- English letters and single spaces, no space at the start or end
Write it in your browser, against the clock. The model solution, stepped through line by line, comes after.
More Strings problems
- Center in a FieldBeginner
- Chunks From the LeftBeginner
- Consecutive CharactersBeginner
- Count Capitalized WordsBeginner
- Count Differing PositionsBeginner
- Count Prefixes of a Given StringBeginner
- Defanging an IP AddressBeginner
- Determine if String Halves Are AlikeBeginner