Interface for a product
TypeScript
Easy
Objective
Create a TypeScript interface for a product
Requirements
The interface should be named
Product
It should have the following required properties:
name
(string)price
(number)instock
(boolean)
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