0
0
Typescriptprogramming~10 mins

String manipulation types (Uppercase, Lowercase) in Typescript - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to convert the string to uppercase.

Typescript
const text = "hello";
const upperText = text.[1]();
console.log(upperText);
Drag options to blanks, or click blank then click option'
Auppercase
BtoUpperCase
CtoLowerCase
Dlowercase
Attempts:
3 left
💡 Hint
Common Mistakes
Using toLowerCase() instead of toUpperCase()
Using incorrect method names like uppercase()
2fill in blank
medium

Complete the code to convert the string to lowercase.

Typescript
const text = "WORLD";
const lowerText = text.[1]();
console.log(lowerText);
Drag options to blanks, or click blank then click option'
AtoUpperCase
Buppercase
Clowercase
DtoLowerCase
Attempts:
3 left
💡 Hint
Common Mistakes
Using toUpperCase() instead of toLowerCase()
Using incorrect method names like lowercase()
3fill in blank
hard

Fix the error in the code to convert the string to uppercase.

Typescript
const greeting = "hello world";
const shout = greeting.[1]();
console.log(shout);
Drag options to blanks, or click blank then click option'
AtoUpperCase
Btouppercase
CtoupperCase
DToUpperCase
Attempts:
3 left
💡 Hint
Common Mistakes
Using wrong casing like touppercase or ToUpperCase
Misspelling the method name
4fill in blank
hard

Fill both blanks to create a new string with the first letter uppercase and the rest lowercase.

Typescript
const word = "jAVAscript";
const fixed = word.charAt(0).[1]() + word.[2](1).toLowerCase();
console.log(fixed);
Drag options to blanks, or click blank then click option'
Aslice
BtoUpperCase
CtoLowerCase
Dsubstring
Attempts:
3 left
💡 Hint
Common Mistakes
Using toLowerCase() for the first blank
Choosing substring instead of slice for the second blank (both work)
Confusing the blanks
5fill in blank
hard

Fill all three blanks to create a function that capitalizes the first letter of a string and makes the rest lowercase.

Typescript
function capitalize(str: string): string {
  return str.[1](0).[2]() + str.[3](1).toLowerCase();
}
Drag options to blanks, or click blank then click option'
AcharAt
BtoUpperCase
Cslice
Dsubstring
Attempts:
3 left
💡 Hint
Common Mistakes
Using substring instead of slice (both work but slice is preferred here)
Forgetting to call toUpperCase() as a function