25.2 When and how to write a function
Have you copy and pasted code more than 2x? Consider a function!
Key steps in creating a function:
Pick a name than makes it clear what the function does
Arguments, or input variable(s), go inside
function
, like sofunction(arguments)
.The code goes inside curly braces
{ }
, afterfunction()
.Check your function with a few inputs to make sure it’s working.