The function is defined within the HTML code and can then by either called or invoked when
needed. You can have functions that only happen once, functions that happen on demand,
functions in response to decisions etc.
The syntax is the word function followed by the name of the function followed by open and
closed parenthesis. You then put the statements that comprise the function into braces.
This code uses the function called theMajor. The onClick event is the event that caused the
function to be executed. In this example, we are passing information to the function. If
the user clicks the CI button or the BU button, the information passed to the function is
the name of the major. As you can see above, theMsg is a parameter of the function
theMajor. When the click even happens, theMajor function is called and the name of the
major is passed to the parameter of the function. You can then go on and use the
parameter as I did in the document.write or in an alert statement etc.