In the code, I am literally typing the function to say "If the passed in type is a, return x, and if the passed in type is b, return y" and then in the body of the code, I'm literally doing exactly the same thing, saying "If the passed in type is a, return this value of type x, and if the passed in type is b, return this value of type y"
The Playground lets you write TypeScript or JavaScript online in a safe and sharable way.