Bird
0
0

Identify the error in this enum declaration:

medium📝 Debug Q6 of 15
Angular - TypeScript in Angular
Identify the error in this enum declaration:
enum Role {
  Admin,
  User = 'user',
  Guest
}
AMissing semicolon after enum declaration
BCannot have more than two members in an enum
CEnum names must be lowercase
DMixing numeric and string enum values without explicit assignments
Step-by-Step Solution
Solution:
  1. Step 1: Check enum value types

    Mixing numeric (Admin) and string (User) values requires all members to have explicit values.
  2. Step 2: Identify missing explicit value

    Guest has no value assigned, causing error.
  3. Final Answer:

    Mixing numeric and string enum values without explicit assignments -> Option D
  4. Quick Check:

    Mixed enums need explicit values [OK]
Quick Trick: All enum members must have explicit values if mixing types [OK]
Common Mistakes:
  • Assuming implicit values work with mixed types
  • Ignoring missing assignments
  • Thinking enum size is limited

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Angular Quizzes