Enums (enumerations) allow you to group values together with friendlier names. Imagine you had a list of names.
Here’s how you would structure the
You can grab the values from the
enum like so:
TypeScript (left) and ES6 (right)
TypeScript can — see that little red underline? That’s Typescript giving us a hint something is horribly gone wrong.
You probably figured this one out (good job) —
toUpperCase() is a type of String method. We’re passing an integer as the argument, thus we can’t call
toUpperCase() on an integer.
Let’s fix it by stating we can only pass the type String as an argument to our
Update your browser to view this website correctly. Update my browser now