Diagram of multiple parameters
Functions
- Functions can have multiple parameters, they should be separated by a comma (and a space for readability)
- The argument is a value passed to a function. The argument becomes the parameter for that specific function call.
- The parameters of a function are only accessible inside that function. (This concept is called variable scope)
- You can store/save the result of a function in a variable.
Storing functions
function double(number) {
return number * 2
}
let firstResult = double(4)
let secondResult = double(10)
Chapter Recap
- Functions can have multiple parameters, they should be separated by a comma (and a space for readability)
- The argument is a value passed to a function. The argument becomes the parameter for that specific function call.
- The parameters of a function are only accessible inside that function. (This concept is called variable scope)
- You can store/save the result of a function in a variable.