Command Palette

Search for a command to run...

Hectal
Phase 0: Start Here: Why TypeScript
TypeScript · Exercise 5 of 5 Previous
Beginner

A Small Typed Bill

Add types to both functions: total takes an array of numbers and returns a number; formatRupees takes a number and returns a string.

The program must print ₹60.00. The checks also make sure total(["10", 20]) and formatRupees("60") are rejected.

What Check tests

  1. Your code has no type errors
  2. total(["10", 20]) is rejected
  3. formatRupees("60") is rejected
  4. The console prints ₹60.00

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.