Interface for a product

TypeScript
Easy

Objective

Create a TypeScript interface for a product

Requirements

  1. The interface should be named Product

  2. It should have the following required properties:

    1. name (string)

    2. price (number)

    3. instock (boolean)

  3. It should have an optional property description (string)

Solution

Here's how I would approach this, but keep in mind there might be other ways to solve this problem.

interface Product { name: string; price: number; instock: boolean; description?: string; }
Click to reveal