HTML and CSS Reference

In-Depth Information

For the exam, you need to understand both conditional and iterative program flow. Condi-

tional program flow enables an application to examine the state of an object or variable to

decide which code path to process. The commands you use to apply the concept of condi-

tional flow are the
if…else
statement, the
switch
statement, and the ternary operator.

This objective covers how to:

■
Evaluate expressions, including using
switch
statements,
if/then
statements, and

operators

■
Work with arrays

■
Implement special types of arrays

■
Use advanced array methods

■
Implement iterative control flow

To use a conditional flow statement, you must evaluate some data against some condition,

which you do by using conditional operators. You can use logical operators to combine

conditional operators. Combining operators is useful when more than one condition must

be met—or at least one condition from a set of conditions must be met—before processing

specific logic. Table 2-1 outlines the available operators.

TABLE 2-1
Conditional and logical operators

Operator

Type

Description

>

Conditional

Evaluates whether the value on the left is greater than the value on the right

<

Conditional

Evaluates whether the value on the right is greater than the value on the left

>=,<=

Conditional

Evaluates the same as > or < but with the additional logic that the values can

also be equal

!=

Conditional

Evaluates whether the values aren't equal

==

Conditional

Evaluates whether the values are equal independent of the underlying data type

===

Conditional

Evaluates whether the values are equal both in value and underlying data type

&&

Logical

The AND logical operator, in which the expressions on both sides must

evaluate to true

||

Logical

The OR logical operator, in which at least one expression on either side must

evaluate to true

Search WWH ::

Custom Search