0
0
Typescriptprogramming~10 mins

Enum member access 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 access the enum member.

Typescript
enum Color { Red, Green, Blue }
const favorite = Color.[1];
Drag options to blanks, or click blank then click option'
AYellow
BRed
CPink
DOrange
Attempts:
3 left
💡 Hint
Common Mistakes
Using a name not declared in the enum.
Trying to access enum members as strings.
2fill in blank
medium

Complete the code to get the numeric value of the enum member.

Typescript
enum Direction { Up = 1, Down, Left, Right }
const dirValue = Direction.[1];
Drag options to blanks, or click blank then click option'
AUp
BSideways
CBackward
DForward
Attempts:
3 left
💡 Hint
Common Mistakes
Using a member name not in the enum.
Confusing string values with numeric enum values.
3fill in blank
hard

Fix the error in accessing the enum member.

Typescript
enum Status { Active = 'ACTIVE', Inactive = 'INACTIVE' }
const currentStatus = Status.[1];
Drag options to blanks, or click blank then click option'
AInactivee
Bactive
CACTIVE
DInactive
Attempts:
3 left
💡 Hint
Common Mistakes
Using lowercase or uppercase strings instead of enum member names.
Misspelling the enum member name.
4fill in blank
hard

Fill both blanks to access the enum member and get its value.

Typescript
enum Fruit { Apple = 5, Banana = 10 }
const fruitName = Fruit.[1];
const fruitValue = Fruit.[2];
Drag options to blanks, or click blank then click option'
AApple
BBanana
COrange
DGrape
Attempts:
3 left
💡 Hint
Common Mistakes
Using names not declared in the enum.
Mixing up member names and values.
5fill in blank
hard

Fill all three blanks to create an enum, access a member, and get its value.

Typescript
enum Vehicle { [1] = 1, [2] = 2, [3] = 3 }
const myVehicle = Vehicle.Car;
Drag options to blanks, or click blank then click option'
ACar
BBike
CTruck
DPlane
Attempts:
3 left
💡 Hint
Common Mistakes
Using invalid or duplicate member names.
Not assigning values to enum members.