×

typescript · level 1 · unit 7 · lesson 2

  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 is a slot where your function catches information.

Picture your function as a machine. Right now it does the same thing every time. Cut a slot in the front, and you can feed in something new on each go.

That slot is a parameter. It sits in the round brackets with a type label, like name: string in function greet(name: string). Inside the block, use it like any variable.

The value you drop in when you call is the . greet("Mia") puts "Mia" into name. Feed it the wrong type, like greet(7), and the checker stops you with TS2345.

function greet(name: string) {
  console.log(`Hello, ${name}!`);
}
greet("Mia");
greet("Leo");

Separate two parameters with commas, and give every slot an argument, or the checker says TS2554.