Oliver Eyton-Williams bd68b70f3d
Feat: hide blocks not challenges (#39504)
* fix: remove isHidden flag from frontmatter

* fix: add isUpcomingChange

Co-authored-by: Ahmad Abdolsaheb <ahmad.abdolsaheb@gmail.com>

* feat: hide blocks not challenges

Co-authored-by: Ahmad Abdolsaheb <ahmad.abdolsaheb@gmail.com>

Co-authored-by: Ahmad Abdolsaheb <ahmad.abdolsaheb@gmail.com>
2020-09-03 15:07:40 -07:00

1.7 KiB

id, title, isRequired, challengeType, forumTopicId
id title isRequired challengeType forumTopicId
ab6137d4e35944e21037b769 Title Case a Sentence true 5 16088

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".

Instructions

Tests

tests:
  - text: <code>titleCase("I&#39;m a little tea pot")</code> should return a string.
    testString: assert(typeof titleCase("I'm a little tea pot") === "string");
  - text: <code>titleCase("I&#39;m a little tea pot")</code> should return <code>I&#39;m A Little Tea Pot</code>.
    testString: assert(titleCase("I'm a little tea pot") === "I'm A Little Tea Pot");
  - text: <code>titleCase("sHoRt AnD sToUt")</code> should return <code>Short And Stout</code>.
    testString: assert(titleCase("sHoRt AnD sToUt") === "Short And Stout");
  - text: <code>titleCase("HERE IS MY HANDLE HERE IS MY SPOUT")</code> should return <code>Here Is My Handle Here Is My Spout</code>.
    testString: assert(titleCase("HERE IS MY HANDLE HERE IS MY SPOUT") === "Here Is My Handle Here Is My Spout");

Challenge Seed

function titleCase(str) {
  return str;
}

titleCase("I'm a little tea pot");

Solution

function titleCase(str) {
  return str.split(' ').map(word => word.charAt(0).toUpperCase() + word.substring(1).toLowerCase()).join(' ');
}

titleCase("I'm a little tea pot");