Question · JavaScript and TypeScript course · Module 6: TypeScript Basics

Union Types

What does the type string | number mean in TypeScript?

Answer options

  • The variable is both a string and a number at the same time
  • The variable can only be null or undefined
  • The variable is converted from a string to a number
  • The variable can be either a string or a number

You can check the correct answer by solving this task in the CodeWorlds game.