Coding task · JavaScript and TypeScript course · Module 6: TypeScript Basics

Union Type with Type Guard

Use union types and type guards to handle different types of dinosaurs in Jurassic Park.

Task

Create a function that takes a parameter of type string | number and uses typeof as a type guard to return the appropriate dinosaur description.