To create a function, you give it a name and then write statements needed to achieve its task inside the curly braces. You declare a function by using the keyword, function. You give the function a name followed by parethesis. Code inside the curly braces is the task that function does. Here's an example:
Function, sayHello() prints a message to the page. Having decalred the function, you can execute all of the statements inside the curly braces by calling the function. To call the function, you simple use the function name with parethesis (sayHello(); is written outside the function).