Bird
0
0

Given this enum and code:

medium📝 state output Q4 of 15
Angular - TypeScript in Angular
Given this enum and code:
enum Direction { Up, Down, Left, Right }
const move = Direction.Left;
console.log(move);

What will be printed in the console?
A0
B3
C2
DLeft
Step-by-Step Solution
Solution:
  1. Step 1: Understand default enum values

    Enums start at 0 by default: Up=0, Down=1, Left=2, Right=3.
  2. Step 2: Identify value of Direction.Left

    Direction.Left equals 2.
  3. Final Answer:

    2 -> Option C
  4. Quick Check:

    Default enum start = 0, Left = 2 [OK]
Quick Trick: Enums start at 0 unless assigned otherwise [OK]
Common Mistakes:
  • Expecting string output
  • Assuming Left = 3
  • Confusing enum values

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Angular Quizzes