Skip to main content

Command Palette

Search for a command to run...

Return value

Updated
1 min read
Return value

Return value is the result directly obtained after executing a unit of code, usually denoted by the reserved word return

It's the easiest exit point to verify because, after getting the value returned by the unit of code, we can compare it with the expected result.

/** 
 * It's common to point the return type in the entry point (signature)
 * In this case is the last ```number``` that specifies 
 * what type this unit of code returns.
 */
function add(summand: number, otherSummand: number): number {
  /** Return value exit point */
  return summand + otherSummand;
}

🇨🇴 Versión en Español