Command Palette

Search for a command to run...

Hectal
Phase 6: Classes and Object-Oriented TypeScript
TypeScript · Exercise 4 of 6 PreviousNext
Intermediate

Two Loggers, One Contract

The Logger interface and the run function are written. Write two classes that implement Logger: MemoryLogger, which stores every message in a public lines array, and PrefixLogger, which takes a prefix in its constructor and prints prefix + message with console.log.

The program should print [app] start, [app] end and then 2.

What Check tests

  1. Your code has no type errors
  2. The console prints [app] start, [app] end and 2
  3. Both classes say implements Logger
  4. A class missing log does not satisfy Logger

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.