×

typescript · level 1 · unit 2 · lesson 1

  1. meet it
  2. guess first
  3. your turn
  4. fix it
  5. nailed it

Tap a green word if you get lost.

meet it

A ="button" class="pl-term" data-term="0" aria-expanded="false">variable is a box with a name and a label.

A variable is a box with a name on it. let name: string = "Sam"; makes a box called name and puts the "Sam" inside. From then on, say the name to get it back.

The : string part is a type label. A type is the kind of value a box may hold: string for text, number for numbers, and for true or false.

Put the wrong kind of value in a box and the checker stops you before anything runs. Think of a jar labelled jam: no pickles allowed.

let name: string = "Sam";
let age: number = 9;
let hungry: boolean = true;
console.log(name, age, hungry);

Read the = as “put into”, not “equals”.