CodingNeed.

1 · Write contracts · 8 MIN

Describe an object

Objects group related properties.

A type alias names an object shape. Properties can have different types. Structural typing means matching shapes are compatible; it does not validate JSON from a server.

A contact card groups a name and age into one record.

Read the example

type Learner = { name: string; points: number };
const learner: Learner = {name:"Ada", points:50};
console.log(learner.name);
Check the expected output
Ada

Your challenge

Return "NAME has POINTS points" using input.name and input.points.

Common trap

input.name and input["name"] work; input[name] looks up the value of a variable called name.

Next lesson: Narrow a union →

Essential cookies keep your account signed in. Optional analytics is not configured on this site. Your choice does not affect access to lessons.

Read the Privacy Policy. You can change this choice in the footer.