Challenge - 5 Problems
Capitalize and Uncapitalize Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ Predict Output
intermediate2:00remaining
What is the output of this Capitalize type example?
Consider the following TypeScript code using the
Capitalize utility type. What is the type of Result?Typescript
type Result = Capitalize<'hello world'>; // What is the type of Result?
Attempts:
2 left
💡 Hint
Capitalize only changes the first character to uppercase, leaving the rest unchanged.
✗ Incorrect
The Capitalize type changes only the first character of the string literal type to uppercase. So 'hello world' becomes 'Hello world'.
❓ Predict Output
intermediate2:00remaining
What is the output of this Uncapitalize type example?
Look at this TypeScript code using the
Uncapitalize utility type. What is the type of Result?Typescript
type Result = Uncapitalize<'Hello World'>; // What is the type of Result?
Attempts:
2 left
💡 Hint
Uncapitalize only changes the first character to lowercase, leaving the rest unchanged.
✗ Incorrect
The Uncapitalize type changes only the first character of the string literal type to lowercase. So 'Hello World' becomes 'hello World'.
🧠 Conceptual
advanced2:00remaining
Which option correctly describes Capitalize and Uncapitalize behavior?
Which statement correctly describes how the TypeScript utility types
Capitalize and Uncapitalize work?Attempts:
2 left
💡 Hint
Think about how only the first letter is affected.
✗ Incorrect
Capitalize and Uncapitalize only affect the first character of a string literal type. They do not change the rest of the string.
❓ Predict Output
advanced2:00remaining
What is the type of Result after nested Capitalize and Uncapitalize?
Given this TypeScript code, what is the type of
Result?Typescript
type Result = Uncapitalize<Capitalize<'tYPEScript'>>; // What is Result?
Attempts:
2 left
💡 Hint
Apply Capitalize first, then Uncapitalize on the result.
✗ Incorrect
Capitalize<'tYPEScript'> makes the first letter uppercase: 'TYPEScript'. Then Uncapitalize<'TYPEScript'> makes the first letter lowercase again: 'tYPEScript'.
❓ Predict Output
expert3:00remaining
What is the output of this mapped type using Capitalize and Uncapitalize?
Consider this TypeScript code that uses mapped types with Capitalize and Uncapitalize. What is the resulting type of
NewObj?Typescript
type Original = {
firstName: string;
lastName: string;
Age: number;
};
type NewObj = {
[K in keyof Original as Capitalize<Uncapitalize<string & K>>]: Original[K]
};Attempts:
2 left
💡 Hint
Uncapitalize then Capitalize on the key name affects only the first letter casing.
✗ Incorrect
For keys 'firstName' and 'lastName', Uncapitalize does nothing (first letter already lowercase), then Capitalize makes first letter uppercase while leaving the rest unchanged: 'FirstName', 'LastName'. For 'Age', Uncapitalize makes 'age', then Capitalize makes 'Age'.