Describe a meeting room
Before you start this intermediate track
JavaScript objects and functions. The lessons introduce narrowing, unions, and optional properties.
Guided code reading and debugging. Runnable coding challenges are available in JavaScript, Python, and SQL.
Predict the result.
What room label is logged?
type Room = { name: string; capacity: number };const room: Room = { name: "Cedar", capacity: 6 };const label = `${room.name}: ${room.capacity} seats`;console.log(label);Use TypeScript 5+ with strict checking and an ES2020 target. Each mission is an independent file. Compile the TypeScript to JavaScript, then run it with Node.js or in a browser console.
Review the lesson
An object type spells out the properties a value must provide and the type of each property. Here, Room requires a text name and a numeric capacity. Annotating room lets TypeScript check that shape before the code runs. The values remain ordinary JavaScript properties when the program builds its display label.