Mo Zargham 437ba8b103 fix(curriculum): Read-search-ask link now point to correct url as noted in the issue (#37753)
* fix: broken Read-search-ask link now point to correct url

* fix: changed link to original forum link with more views

* fix: changed http links to correct version

* fix: link in help modal
2019-11-19 19:54:48 -05:00

2.2 KiB
Raw Blame History

id, title, isRequired, challengeType, forumTopicId, localeTitle
id title isRequired challengeType forumTopicId localeTitle
ab6137d4e35944e21037b769 Title Case a Sentence true 5 16088 Название Случайное предложение

Description

Верните предоставленную строку с первой буквой каждого слова, заглавными. Убедитесь, что остальная часть слова находится в нижнем регистре. Для целей этого упражнения вы также должны использовать прописные слова, такие как «the» и «of». Не забудьте использовать Read-Search-Ask, если вы застряли. Напишите свой собственный код.

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");