Promptles
Programming Basics

Return Value

beginner

Definition

The output a function sends back to the code that called it. When a function reaches a 'return' statement, it stops running and hands back that value. The calling code can then store it in a variable, display it, or pass it to another function.

In the wild

function double(n) { return n * 2; }: calling double(5) returns 10. You can capture it: let result = double(5); Now 'result' holds the value 10.

More from Programming Basics