← All Exercises
Capitalize Words
basicjavascript
Background
Capitalizing words is common in title formatting, name normalization, and user-facing text display.
Problem
Write a function that takes a string of words separated by spaces and returns a new string where each word starts with an uppercase letter.
Input
A string of words separated by single spaces.
Output
A string with each word capitalized (first letter uppercase, rest lowercase).
Sample tests
Sample 1
Input: "hello world"
Expected: "Hello World"
Your solution
Learning objective
Practice string splitting, mapping, and case transformation methods.