Put in order · JavaScript and TypeScript course · Module 7: Advanced TypeScript

Structure of a function with early returns

Order the elements in a function that uses early returns (top to bottom):

Items to put in order

  • Check invalid input and return
  • Check remaining edge cases and return
  • Return the success result
  • Main business logic

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