...
/Coding Challenge: Create Algebraic Data Type
Coding Challenge: Create Algebraic Data Type
Let's create an algebraic data type.
We'll cover the following...
Problem statement
In this challenge, create an algebraic data type (sum type) for a vehicle. The type of vehicle will be either a car or a bicycle. A car will have two properties: mileage
and numberOfSeats,
both properties of type number
. On the other hand, a bicycle has a single property called luggageRack
of type boolean.
Try it yourself
You can implement your solution in the code widget provided below.
Access this course and 1400+ top-rated courses and projects.