Deep Dive: The return statement
In JavaScript, functions return undefined by default if no return statement is specified. When you use return, you are doing two things:
- Stopping the function's execution immediately.
- Passing a specific value back to the "call site".