Writing Expressions : Basic concepts : Multiline expressions
 
Multiline expressions
An expression can contain multiple lines, as shown in the following example:
firstInitial = row["customerFirstname"].charAt(0);
firstInitial + ". " + row["customerLastname"];
The expression looks like lines of program code because it is. Expressions can be small pieces of code that do something. The expression in the previous example does the following tasks:
*It extracts the first character of a string value in a customerFirstname field and assigns the value to a variable named firstInitial.
*Then, it combines the firstInitial value, a period, a space, and the value in a customerLastname field.
An expression can contain as many lines as needed. Just remember that an expression returns a single value. If an expression contains several lines, it returns the results of the last line. The previous expression returns a value, such as T. Robinson.
The lines are called statements, and they are separated from each other by semicolons. If you place each statement on a separate line, as shown in the example, JavaScript allows you to leave out the semicolons. It is, however, good practice to use semicolons to separate statements.