Return Statements

Learn the last powerful part of functions. The return statement allows a function to send information back out. With this final tool, we can master the full power of functions.

Introduction

There’s one more powerful feature of functions. The return statement. In addition to accepting values in through arguments, a function can send something back out.

Here’s how that works.

Press + to interact
function add10(number) {
let newNumber = number + 10;
return newNumber;
}
let fifteen = add10(5);
console.log(fifteen); // -> 15

Breakdown

We give add10 a value of 5 when we call it. Inside the function, a new variable newNumber is created, which is equal to what was passed in plus 10.

We then return newNumber ...