Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete 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'
Attempts:
3 left
💡 Hint
Common Mistakes
Using a name not declared in the enum.
Trying to access enum members as strings.
✗ Incorrect
The enum member Red is accessed using Color.Red.
2fill in blank
mediumComplete 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'
Attempts:
3 left
💡 Hint
Common Mistakes
Using a member name not in the enum.
Confusing string values with numeric enum values.
✗ Incorrect
The enum member Up has the numeric value 1, accessed by Direction.Up.
3fill in blank
hardFix 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'
Attempts:
3 left
💡 Hint
Common Mistakes
Using lowercase or uppercase strings instead of enum member names.
Misspelling the enum member name.
✗ Incorrect
Enum members are case-sensitive. The correct member is Inactive, not active or ACTIVE.
4fill in blank
hardFill 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'
Attempts:
3 left
💡 Hint
Common Mistakes
Using names not declared in the enum.
Mixing up member names and values.
✗ Incorrect
Fruit.Apple and Fruit.Banana access the enum members correctly.
5fill in blank
hardFill 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'
Attempts:
3 left
💡 Hint
Common Mistakes
Using invalid or duplicate member names.
Not assigning values to enum members.
✗ Incorrect
The enum members are Car, Bike, and Truck. They are assigned values 1, 2, and 3 respectively.