Code examples

Give change

Subtract the price from the amount paid to find the change.

Simple example

Start5 − 2
Result3
lesson.ts
console.log((5 - 2));
Output
3
Advertisements

Everyday examples

A customer pays 20 for a meal costing 13. How much change should they get?

Start20 − 13
Result7
lesson.ts
const paid: number = 20;
const price: number = 13;
console.log((paid - price));
Output
7
Run the example
Terminal
tsc --target ES2020 lesson.ts
node lesson.js
Official documentation