: if the function accepts arguments, then open a block with { and close it with } on its own line.
Function names follow the same naming rules as variables — they must be alphanumeric, cannot start with a number or special character, and cannot share a name with a Standard reserved word. See Variables & Types for the full list of reserved words.
Defining a Function
1
Choose a name
Pick a descriptive, alphanumeric name that is not a reserved word and does not conflict with any variable name in your program.
2
Declare arguments (optional)
If your function needs input, follow the name with
: and then the argument name(s). Omit the : entirely for functions that take no arguments.3
Write the function body
Open the block with
{ on the same line as the function name, write your code on the lines that follow, and close the block with } on its own line.Calling a Function
To call a function with no arguments, write its name on a new line. To call a function that expects arguments, write its name followed by: and the value(s) to pass in: