Files
wehub-resource-sync dde272c4b8
i18n - Build Validation / Validate i18n Builds (24) (push) Has been cancelled
CI - Node.js / Lint (24) (push) Has been cancelled
CI - Node.js / Build (24) (push) Has been cancelled
CI - Node.js / Test (24) (push) Has been cancelled
CI - Node.js / Test - Upcoming Changes (24) (push) Has been cancelled
CI - Node.js / Test - i18n (italian, 24) (push) Has been cancelled
CI - Node.js / Test - i18n (portuguese, 24) (push) Has been cancelled
CD - Docker - GHCR Images / Build and Push Images (push) Has been cancelled
chore: import upstream snapshot with attribution
2026-07-13 11:55:53 +08:00

1.3 KiB

id, title, challengeType, dashedName
id title challengeType dashedName
691b559495c5cb5a37b9b486 Challenge 126: Capitalize It 28 challenge-126

--description--

Given a string title, return a new string formatted in title case using the following rules:

  • Capitalize the first letter of each word.
  • Make all other letters in each word lowercase.
  • Words are always separated by a single space.

--hints--

titleCase("hello world") should return "Hello World".

assert.equal(titleCase("hello world"), "Hello World");

titleCase("the quick brown fox") should return "The Quick Brown Fox".

assert.equal(titleCase("the quick brown fox"), "The Quick Brown Fox");

titleCase("JAVASCRIPT AND PYTHON") should return "Javascript And Python".

assert.equal(titleCase("JAVASCRIPT AND PYTHON"), "Javascript And Python");

titleCase("AvOcAdO tOAst fOr brEAkfAst") should return "Avocado Toast For Breakfast".

assert.equal(titleCase("AvOcAdO tOAst fOr brEAkfAst"), "Avocado Toast For Breakfast");

--seed--

--seed-contents--

function titleCase(title) {
  return title;
}

--solutions--

function titleCase(title) {
  return title
    .split(" ")
    .map(word => word.charAt(0).toUpperCase() + word.slice(1).toLowerCase())
    .join(" ");
}