* feat(tools): add seed/solution restore script * chore(curriculum): remove empty sections' markers * chore(curriculum): add seed + solution to Chinese * chore: remove old formatter * fix: update getChallenges parse translated challenges separately, without reference to the source * chore(curriculum): add dashedName to English * chore(curriculum): add dashedName to Chinese * refactor: remove unused challenge property 'name' * fix: relax dashedName requirement * fix: stray tag Remove stray `pre` tag from challenge file. Signed-off-by: nhcarrigan <nhcarrigan@gmail.com> Co-authored-by: nhcarrigan <nhcarrigan@gmail.com>
1.4 KiB
1.4 KiB
id, title, challengeType, forumTopicId, dashedName
id | title | challengeType | forumTopicId | dashedName |
---|---|---|---|---|
ab6137d4e35944e21037b769 | 句中单词首字母大写 | 5 | 16088 | title-case-a-sentence |
--description--
请将传入的字符串中,每个单词的第一个字母变成大写并返回。注意除首字母外,其余的字符都应是小写的。
另外请注意,像是 “the”、“of” 之类的连接词的首字母也要大写。
--hints--
titleCase("I'm a little tea pot")
应返回一个字符串。
assert(typeof titleCase("I'm a little tea pot") === 'string');
titleCase("I'm a little tea pot")
应返回 I'm A Little Tea Pot
。
assert(titleCase("I'm a little tea pot") === "I'm A Little Tea Pot");
titleCase("sHoRt AnD sToUt")
应返回 Short And Stout
。
assert(titleCase('sHoRt AnD sToUt') === 'Short And Stout');
titleCase("HERE IS MY HANDLE HERE IS MY SPOUT")
应返回 Here Is My Handle Here Is My Spout
。
assert(
titleCase('HERE IS MY HANDLE HERE IS MY SPOUT') ===
'Here Is My Handle Here Is My Spout'
);
--seed--
--seed-contents--
function titleCase(str) {
return str;
}
titleCase("I'm a little tea pot");
--solutions--
function titleCase(str) {
return str.split(' ').map(word => word.charAt(0).toUpperCase() + word.substring(1).toLowerCase()).join(' ');
}
titleCase("I'm a little tea pot");