Javascript if, else, and switch Statements

Decision Making in JavaScript

The if and switch Statements

Decision Making Example

Comparison Operators

Symbol

Purpose

==

is equal to

<

is less than

>

is greater than

<=

is less than or equal to

>=

is greater than or equal to

!=

is not equal to

Assignment versus Comparison

The if Statement

The if Statement cont.

Example if Statement

Try It Out – The if Statement

Try It Out – The if Statement cont.

Try It Out – The if Statement cont. 2

Logical Operators

Operator

Symbol

AND

&&

OR

||

NOT

!

AND Operator

OR Operator

NOT Operator

The else Statement

The else if Statement

Comparing Strings

The switch Statement

switch Statement Elements

Try It Out – Using the switch Statement

How It Works

Questions?