Numeric enums
📖 Scenario: Imagine you are creating a simple program to represent the days of the week using numbers. Each day will have a number starting from 0 for Sunday, 1 for Monday, and so on.
🎯 Goal: You will create a numeric enum called Days for the days of the week, then write code to get the number for Wednesday and print it.
📋 What You'll Learn
Create a numeric enum called
Days with days Sunday to Saturday starting at 0Create a variable called
midWeek and assign it the value of Days.WednesdayPrint the value of
midWeek to the console💡 Why This Matters
🌍 Real World
Numeric enums are useful when you want to represent a fixed set of related constants with numbers, like days, months, or status codes.
💼 Career
Understanding enums helps in writing clear and maintainable code in TypeScript, which is widely used in web development and software engineering jobs.
Progress0 / 4 steps