Command Palette

Search for a command to run...

Hectal
Phase 12: The Compiler and tsconfig
TypeScript · Exercise 2 of 6 PreviousNext
Beginner

A Value That May Be Missing

displayName should show a user's nickname in capital letters, or their real name in capital letters when they have no nickname. The first version crashes for users without a nickname, and strictNullChecks already points at the line.

Fix it without ! (the non-null assertion) so the console prints ASH and BO.

What Check tests

  1. Your code has no type errors
  2. The console prints ASH and BO
  3. A user with no name is rejected
  4. You did not use the ! assertion

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.