Skip to main content
🧩 Algorithms & Problem Solving

Title Case

Transform a sentence so each word starts uppercase and the rest is lowercase β€” "hello WORLD" β†’ "Hello World". Split on spaces, transform each word, rejoin.

"hello".charAt(0).toUpperCase() + "hello".slice(1); // "Hello"

Your task

Write titleCase(str) that capitalizes the first letter of each space-separated word and lowercases the rest.

⚑ 35 XP
solution.jsRuns in your browser
Loading editor…
Tests2 to pass
"hello world"
mixed case

Run your code to check these.