Predict Enum Value Output
Predict Output Easy
Question
What does this code print?
Code
enum Direction {
Up,
Down,
Left,
Right,
}
console.log(Direction.Up);
console.log(Direction.Down);
console.log(Direction.Left);
console.log(Direction.Right);
Hint
Numeric enums start at 0 by default and increment by 1.
Explanation
Numeric enums auto-assign values starting at 0. Up=0, Down=1, Left=2, Right=3. The output is 0, 1, 2, 3 each on its own line. Unlike type annotations, enums are not erased — they compile to real JavaScript objects.
Look up unfamiliar terms
A beginner-friendly glossary explains jargon in plain English — variables, functions, DOM, Promise, and more.
Decode error messages
Plain-English explanations of common errors — what they mean, why they happen, and how to fix them.
Build real projects
Apply what you learned by building guided projects with starter code and solutions.