Complete the code to get the length of the string.
const str = "hello"; const length = str.[1];
The length property returns the number of characters in a string in TypeScript.
Complete the code to get the character at index 2.
const str = "world"; const char = str.[1](2);
The charAt method returns the character at the specified index in a string.
Fix the error in the code to convert the string to uppercase.
const str = "test"; const upper = str.[1]();
The correct method to convert a string to uppercase in TypeScript is toUpperCase().
Fill both blanks to create a substring from index 1 to 4.
const str = "example"; const sub = str.[1]([2], 4);
The substring method extracts characters from index 1 up to but not including index 4.
Fill all three blanks to create a new string with the first letter capitalized.
const str = "hello"; const capitalized = str.[1](0, 1).[2]() + str.[3](1);
This code takes the first letter using substring(0, 1), converts it to uppercase, then adds the rest of the string using slice(1).
