Command Palette

Search for a command to run...

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

The List That Might Be Empty

firstWord promises a string, but with noUncheckedIndexedAccess the item words[0] is string | undefined. Fix the function so an empty list gives the text (none).

Do not change the return type.

What Check tests

  1. Your code has no type errors
  2. The first call prints red
  3. The empty list prints (none)
  4. The return type is still string

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.