feat(curriculum): convert title case challenge to lab (#62108)

Co-authored-by: Ilenia <26656284+ilenia-magoni@users.noreply.github.com>
This commit is contained in:
Zaira
2025-09-22 21:31:43 +05:00
committed by GitHub
parent 00a015cd92
commit aee89b025b
5 changed files with 113 additions and 0 deletions

View File

@@ -3436,6 +3436,12 @@
"In these lectures, you will learn about the <code>var</code> keyword and why it is not recommended for use anymore. You will also learn about hoisting in JavaScript so you can avoid subtle bugs in your code."
]
},
"lab-title-case-converter": {
"title": "Build a Title Case Converter",
"intro": [
"In this lab, you will build a function that converts a string to title case."
]
},
"lab-falsy-remover": {
"title": "Implement a Falsy Remover",
"intro": [

View File

@@ -0,0 +1,9 @@
---
title: Introduction to the Build a Title Case Converter
block: lab-title-case-converter
superBlock: full-stack-developer
---
## Introduction to the Build a Title Case Converter
In this lab, you will build a function that converts a string to title case.

View File

@@ -0,0 +1,82 @@
---
id: ab6137d4e35944e21037b769
title: Build a Title Case Converter
challengeType: 26
dashedName: build-a-title-case-converter
---
# --description--
In this lab you will create a function that converts a string to title case. Title case means that the first letter of each word is capitalized and the rest of the word is in lower case.
`"Web Development Is Awesome"` is an example of a title cased string.
**Objective**: Fulfill the user stories below and get all the tests to pass to complete the lab.
**User Stories:**
1. You should have a `titleCase` function that takes a string as an argument.
1. The `titleCase` function should return a string with the first letter of each word capitalized and the rest of the word in lower case.
1. `titleCase("I like to code")` should return `"I Like To Code"`.
1. `titleCase("javaScript is fun")` should return `"Javascript Is Fun"`.
# --hints--
You should create a function named `titleCase`.
```js
assert.isFunction(titleCase);
```
`titleCase` should take a single argument.
```js
assert.lengthOf(titleCase, 1);
```
`titleCase("I'm a little tea pot")` should return a string.
```js
assert.isString(titleCase("I'm a little tea pot"));
```
`titleCase("I'm a little tea pot")` should return the string `I'm A Little Tea Pot`.
```js
assert.strictEqual(titleCase("I'm a little tea pot"), "I'm A Little Tea Pot");
```
`titleCase("sHoRt AnD sToUt")` should return the string `Short And Stout`.
```js
assert.strictEqual(titleCase('sHoRt AnD sToUt'), 'Short And Stout');
```
`titleCase("HERE IS MY HANDLE HERE IS MY SPOUT")` should return the string `Here Is My Handle Here Is My Spout`.
```js
assert.strictEqual(
titleCase('HERE IS MY HANDLE HERE IS MY SPOUT'),
'Here Is My Handle Here Is My Spout'
);
```
# --seed--
## --seed-contents--
```js
```
# --solutions--
```js
function titleCase(str) {
return str
.split(' ')
.map(word => word.charAt(0).toUpperCase() + word.substring(1).toLowerCase())
.join(' ');
}
```

View File

@@ -0,0 +1,15 @@
{
"name": "Build a Title Case Converter",
"isUpcomingChange": false,
"dashedName": "lab-title-case-converter",
"helpCategory": "JavaScript",
"blockLayout": "link",
"blockType": "lab",
"challengeOrder": [
{
"id": "ab6137d4e35944e21037b769",
"title": "Build a Title Case Converter"
}
],
"usesMultifileEditor": true
}

View File

@@ -382,6 +382,7 @@
"lab-pyramid-generator",
"lab-gradebook-app",
"lecture-the-var-keyword-and-hoisting",
"lab-title-case-converter",
"lab-falsy-remover",
"lab-inventory-management-program",
"lecture-understanding-modules-imports-and-exports",