Oliver Eyton-Williams ee1e8abd87
feat(curriculum): restore seed + solution to Chinese (#40683)
* 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>
2021-01-12 19:31:00 -07:00

1.3 KiB

id, title, challengeType, forumTopicId, dashedName
id title challengeType forumTopicId dashedName
ab6137d4e35944e21037b769 Title Case a Sentence 5 16088 title-case-a-sentence

--description--

Return the provided string with the first letter of each word capitalized. Make sure the rest of the word is in lower case.

For the purpose of this exercise, you should also capitalize connecting words like "the" and "of".

--hints--

titleCase("I'm a little tea pot") should return a string.

assert(typeof titleCase("I'm a little tea pot") === 'string');

titleCase("I'm a little tea pot") should return I'm A Little Tea Pot.

assert(titleCase("I'm a little tea pot") === "I'm A Little Tea Pot");

titleCase("sHoRt AnD sToUt") should return Short And Stout.

assert(titleCase('sHoRt AnD sToUt') === 'Short And Stout');

titleCase("HERE IS MY HANDLE HERE IS MY SPOUT") should return 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");