## With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

No credit card required

# Boolean Logic

Early in this chapter, we saw how to make logical decisions using test expressions that yield Boolean values. The decisions were based on a single factor, such as "if `language` is `"english"`, then display "`Hello`". But not all programming logic is so simple. Programs often need to consider multiple factors in branching logic (i.e., decision making). To manage multiple factors in a test expression, we use the Boolean operators: `||` (logical OR) and `&&` (logical AND).

## Logical OR

The logical OR operator is most commonly used to initiate some action when at least one of two conditions is met. For example, "If I am hungry or I am thirsty, I'll go to the kitchen." The symbol for logical OR is made using two "pipe" characters: `||`. Typically, the pipe character (`|`) is accessible using the Shift key and the Backslash (`\`) key in the upper right of most Western keyboards, where it may be depicted as a dashed vertical line. Logical OR has the following general form:

``expression1` || `expression2``

When both `expression1` and `expression2` are Boolean values or evaluate to Boolean values, logical OR returns `true` if either expression is `true` and returns `false` only if both expression are `false`. In summary:

```true  || false   // true because first operand is true
false || true    // true because second operand is true
true  || true    // true (however, either operand being true is sufficient)
false || false   // false because both operands are false```

When `expression1` is not a Boolean value, ActionScript first converts ...

## With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

No credit card required