--- id: ab6137d4e35944e21037b769 title: Title Case a Sentence isRequired: true challengeType: 5 videoUrl: '' localeTitle: 标题案例句子 --- ## Description
返回提供的字符串,每个单词的首字母大写。确保单词的其余部分为小写。出于本练习的目的,您还应该将诸如“the”和“of”之类的连接词大写。如果卡住,请记得使用Read-Search-Ask 。编写自己的代码。
## Instructions
## Tests
```yml tests: - text: 'titleCase("I'm a little tea pot")应该返回一个字符串。' testString: 'assert(typeof titleCase("I"m a little tea pot") === "string", "titleCase("I'm a little tea pot") should return a string.");' - text: 'titleCase("I'm a little tea pot")应该归还I'm A Little Tea Pot 。' testString: 'assert(titleCase("I"m a little tea pot") === "I"m A Little Tea Pot", "titleCase("I'm a little tea pot") should return I'm A Little Tea Pot.");' - text: titleCase("sHoRt AnD sToUt")应返回Short And Stout 。 testString: 'assert(titleCase("sHoRt AnD sToUt") === "Short And Stout", "titleCase("sHoRt AnD sToUt") should return Short And Stout.");' - text: titleCase("HERE IS MY HANDLE HERE IS MY SPOUT") Here Is My Handle Here Is My Spout titleCase("HERE IS MY HANDLE HERE IS MY SPOUT")应该回到Here Is My Handle Here Is My Spout 。 testString: 'assert(titleCase("HERE IS MY HANDLE HERE IS MY SPOUT") === "Here Is My Handle Here Is My Spout", "titleCase("HERE IS MY HANDLE HERE IS MY SPOUT") should return Here Is My Handle Here Is My Spout.");' ```
## Challenge Seed
```js function titleCase(str) { return str; } titleCase("I'm a little tea pot"); ```
## Solution
```js // solution required ```