0
0
Typescriptprogramming~10 mins

What is TypeScript - Interactive Quiz & Practice

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

Complete the code to declare a variable with a type in TypeScript.

Typescript
let age: [1] = 25;
Drag options to blanks, or click blank then click option'
Aboolean
Bstring
Cnumber
Dany
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'string' instead of 'number' for numeric values.
Omitting the type annotation.
2fill in blank
medium

Complete the code to define a function that returns a string in TypeScript.

Typescript
function greet(): [1] {
  return "Hello!";
}
Drag options to blanks, or click blank then click option'
Avoid
Bboolean
Cnumber
Dstring
Attempts:
3 left
💡 Hint
Common Mistakes
Using void when the function returns a value.
Using number or boolean incorrectly.
3fill in blank
hard

Fix the error in the TypeScript interface declaration.

Typescript
interface Person {
  name: string;
  age: [1];
}
Drag options to blanks, or click blank then click option'
Astring
Bnumber
Cboolean
Dany
Attempts:
3 left
💡 Hint
Common Mistakes
Using string for numeric properties.
Leaving the type undefined.
4fill in blank
hard

Fill both blanks to create a typed array of strings in TypeScript.

Typescript
let fruits: [1] = ["apple", "banana", "cherry"]; // array of [2]
Drag options to blanks, or click blank then click option'
Astring[]
Bnumber[]
Cstring
Dboolean[]
Attempts:
3 left
💡 Hint
Common Mistakes
Using number[] or boolean[] for string arrays.
Confusing the array type with the element type.
5fill in blank
hard

Fill all three blanks to create a typed object with optional and readonly properties in TypeScript.

Typescript
interface Car {
  readonly make: [1];
  model: [2];
  year?: [3];
}
Drag options to blanks, or click blank then click option'
Astring
Bnumber
Cboolean
Dany
Attempts:
3 left
💡 Hint
Common Mistakes
Using boolean for text or number properties.
Forgetting the optional property syntax.