Functions, Part II
Function Syntax

The typical structure of a function is as follows:

function name(parameters) {
  1. The keyword function indicates that the code following it will be a user-defined function.

  2. name indicates the name of a function, which is case insensitive. The name of a function can contain numbers, letters, underscores or dashes.

  3. The arguments, or parameters, will be the optional input a function uses to perform calculations.

  4. And of course, the statements themselves will be the code the function executes when it is called.


Take a look at the helloWorld() function to the right. It takes no parameters, and when called it will simply print the string "Hello world!".

Press Save & Submit Code to continue to the next exercise.

View Preview