Code examples

Count parcels after a delivery

Add what came in, then subtract what went out.

Simple example

Start2 + 3 − 1
Result4
lesson.ts
console.log(((2 + 3) - 1));
Output
4
Advertisements

Everyday examples

Two boxes hold 6 and 4 parcels. Three parcels go out. How many are left?

Start6 + 4 − 3
Result7
lesson.ts
const first: number = 6;
const second: number = 4;
const sent: number = 3;
console.log(((first + second) - sent));
Output
7
Run the example
Terminal
tsc --target ES2020 lesson.ts
node lesson.js
Official documentation