๐
Title Case
Title Case๋ณดํต ๋ฌธ์์ด +20pts
Problem
Write a function that capitalizes the first letter of each word.
Examples
Input:
titleCase("hello world")Output:
"Hello World"Explanation
์ด ๋ฌธ์ ๋ **split, map, join**์ ์กฐํฉํ์ฌ ์ ๋ชฉ ํ์(Title Case)์ผ๋ก ๋ณํํ๋ ๋ฐฉ๋ฒ์ ํ์ตํฉ๋๋ค. ## ํต์ฌ ๊ฐ๋ : ๋ฌธ์์ด ๋ณํ ํ์ดํ๋ผ์ธ ์ฌ๋ฌ ๋ฌธ์์ด ๋ฉ์๋๋ฅผ ์ฒด์ด๋ํ์ฌ ๋ณต์กํ ๋ณํ์ ์ํํฉ๋๋ค. ### ์ ๊ทผ ๋ฐฉ๋ฒ ```javascript str.split(' ') .map(word => word.charAt(0).toUpperCase() + word.slice(1).toLowerCase()) .join(' ') ``` ### ๋จ๊ณ๋ณ ๋ถ์ 1. split(' '): ๊ณต๋ฐฑ์ผ๋ก ๋จ์ด ๋ถ๋ฆฌ 2...
View detailed explanation โKey Concepts
split-map-join ํจํด ๋ฌธ์์ด ์ฒด์ด๋ Title Case ๋ฌธ์์ด ๋ณํ
Time: O(n) Space: O(n)
solution.js
Ctrl + Enter
Run tests to see results here.