Command Palette

Search for a command to run...

Hectal
Phase 8: Type Operators
TypeScript · Exercise 3 of 5 PreviousNext
Beginner

The type of one cart line

A Cart has a list of lines. Without retyping the line shape, define Line (one entry of Cart["lines"]) and Price (the type of a line's price).

Use indexed access with [number]. Then lineTotal should compile, and the program should print 45.

What Check tests

  1. Your code has no type errors
  2. The console prints 45
  3. A full line is accepted
  4. A line without price and qty is rejected
  5. Price is a number, not text

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.