Deﬁning a Function the type of value we expect to be ‘returned’ the arguments we can pass in returnType functionName( argumentList ) { // some code goes here }

the variable type we expect to be ‘returned’ the arguments we will pass in returnType functionName( argumentList ) { // some code goes here } 1. Function Name: a name! 2. Input: the variable types of arguments we will pass in! 3. Output: the variable type that will be returned ( void signiﬁes that we do not expect returned value )

Demo! square() function

Why functions? • Functions organize code in a way that humans can understand! • Modularity: smaller, more readable, more manageable bits of code; it’s debuggable!! • Reusability: you can reuse code within a sketch (two pong paddles) or between sketches