Enum member access
📖 Scenario: You are creating a simple program to manage directions in a navigation app.
🎯 Goal: You will create an enum for directions and access its members to display a chosen direction.
📋 What You'll Learn
Create an enum called
Direction with members Up, Down, Left, and Right assigned to 1, 2, 3, and 4 respectively.Create a variable called
chosenDirection and assign it the enum member Direction.Left.Create a variable called
directionName that gets the name of the enum member from chosenDirection.Print the value of
chosenDirection and directionName.💡 Why This Matters
🌍 Real World
Enums help represent fixed sets of related values like directions, statuses, or categories in apps.
💼 Career
Understanding enums is important for writing clear and maintainable code in TypeScript, common in web development jobs.
Progress0 / 4 steps