Command Palette

Search for a command to run...

Hectal
Phase 1: Basic Types and Annotations
TypeScript · Exercise 2 of 6 PreviousNext
Beginner

Allow Only Two Choices

The function turn accepts any text, so turn("up") is allowed. Change the parameter type so that only "left" and "right" are accepted.

Keep the function body as it is.

What Check tests

  1. Your code has no type errors
  2. The console prints Turning left
  3. turn("up") is rejected
  4. turn("right") is accepted

Stuck? One hint at a time

The solution unlocks after your first Check. Try first: that is where the learning happens.

Runs in your browser. Your code is saved here.

Console

Nothing printed yet.