Skip to content

Challenge Return Early Pattern For Functions

SaintPeter edited this page · 2 revisions
Clone this wiki locally

Challenge: Return Early Pattern for Functions

When a return statement is reached, the execution of the current function stops and control returns to the calling location.

Example

function myFun() {
  console.log("Hello");
  return "World";
  console.log("byebye")
}
myFun();

The above outputs "Hello" to the console, returns "World", but "byebye" is never output, because the function exits at the return statement.

Something went wrong with that request. Please try again.