0
0
Typescriptprogramming~10 mins

Declaring global variables 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 declare a global variable named count with initial value 0.

Typescript
let [1] = 0;
Drag options to blanks, or click blank then click option'
Avalue
Bcount
Cnumber
Dtotal
Attempts:
3 left
💡 Hint
Common Mistakes
Using a wrong variable name like 'total' or 'value'.
Forgetting to declare the variable with 'let'.
2fill in blank
medium

Complete the code to declare a global constant named MAX_USERS with value 100.

Typescript
const [1] = 100;
Drag options to blanks, or click blank then click option'
AMAX_USERS
BmaxUsers
Cmax_users
DMaxUsers
Attempts:
3 left
💡 Hint
Common Mistakes
Using lowercase or camelCase instead of uppercase with underscores.
Using let instead of const.
3fill in blank
hard

Fix the error in the code to declare a global variable username of type string.

Typescript
let [1]: string = "guest";
Drag options to blanks, or click blank then click option'
Auser_name
Bname
Cuser
Dusername
Attempts:
3 left
💡 Hint
Common Mistakes
Using underscores or different variable names.
Missing the type annotation : string.
4fill in blank
hard

Fill both blanks to declare a global variable isActive of type boolean with initial value true.

Typescript
let [1]: [2] = true;
Drag options to blanks, or click blank then click option'
AisActive
Bboolean
Cstring
Dactive
Attempts:
3 left
💡 Hint
Common Mistakes
Using wrong variable names like 'active'.
Using wrong types like 'string' instead of 'boolean'.
5fill in blank
hard

Fill all three blanks to declare a global constant API_URL of type string with value "https://api.example.com".

Typescript
const [1]: [2] = [3];
Drag options to blanks, or click blank then click option'
AAPI_URL
Bstring
C"https://api.example.com"
Durl
Attempts:
3 left
💡 Hint
Common Mistakes
Using wrong variable names like 'url'.
Missing quotes around the URL string.
Using wrong types like 'boolean'.