0
0
Typescriptprogramming~15 mins

Capitalize and Uncapitalize types in Typescript - Mini Project: Build & Apply

Choose your learning style9 modes available
Capitalize and Uncapitalize Types in TypeScript
📖 Scenario: Imagine you are working on a user interface where you need to format strings to show names properly. Sometimes you want the first letter capitalized, and other times you want it lowercase.
🎯 Goal: You will create TypeScript types that change the first letter of a string type to uppercase or lowercase using Capitalize and Uncapitalize utility types.
📋 What You'll Learn
Create a string type called originalName with the value 'helloWorld'.
Create a type called capitalizedName that uses Capitalize on originalName.
Create a type called uncapitalizedName that uses Uncapitalize on capitalizedName.
Print the values of capitalizedName and uncapitalizedName as strings.
💡 Why This Matters
🌍 Real World
Formatting user names, titles, or labels in user interfaces to follow style guides.
💼 Career
Understanding TypeScript utility types helps write safer and cleaner code in frontend and backend projects.
Progress0 / 4 steps
1
Create the original string type
Create a string type called originalName with the exact value 'helloWorld'.
Typescript
Need a hint?

Use type originalName = 'helloWorld'; to create the string type.

2
Create a capitalized type
Create a type called capitalizedName that uses Capitalize on originalName.
Typescript
Need a hint?

Use type capitalizedName = Capitalize; to capitalize the first letter.

3
Create an uncapitalized type
Create a type called uncapitalizedName that uses Uncapitalize on capitalizedName.
Typescript
Need a hint?

Use type uncapitalizedName = Uncapitalize; to uncapitalize the first letter.

4
Print the capitalized and uncapitalized types
Write two console.log statements to print the values of capitalizedName and uncapitalizedName as strings. Use type assertions to convert types to strings.
Typescript
Need a hint?

Assign the string values to constants with the correct types, then print them.