Return Value
beginnerDefinition
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
Function
A reusable block of code that performs a specific task. You give it a name, and whenever you need that task done, you 'call' the function by name instead of writing the same code again. Functions can accept inputs and produce outputs.
Parameter
A variable listed in a function's definition that acts as a placeholder for data the function will receive when it's called. Parameters let you write one function that works with many different inputs instead of hard-coding specific values.
Variable
A named container that holds a value in your program. Think of it like a labeled box: the label is the variable's name, and inside is the data (a number, some text, a list, etc.). You can read what's inside, replace it, or use it in calculations.