Animations
API
Arrays
Async
Basics
Challenges
Classes
Console
Dates
Debugging
DOM Elements
DOM Methods
DOM Properties
Event Listeners
Flow Control
Forms
Functions
Global Functions
JSON
Keywords
Libraries (3rd party)
Math
Modules
Objects
Snippets
String
Types
Widgets
Window Object
the return keyword
The return statement stops the execution of a function and returns a value from that function.
Tip: If you plan to break up the return statement and use parenthesis, keep the opening parenthesis on the same
line - proceeding the return
statement.
// this will NOT work
function GetMessage()
{
return ("Hello World!...lots of code/content here" );
}
console.log(GetMessage());
// this WILL work
function GetMessage()
{
return ( "Hello World!...lots of code/content here");
}
console.log(GetMessage());
// this is even better
function GetMessage()
{
let message = "Hello World!...lots of code/content here";
return message;
}
console.log(GetMessage());