Northcentral Technical College Introduction To Programming
10-152-310
Introduction to Programming with JavaScript NTC 10-152-310

Learning Unit 3 Simple if/else Statments

# Simple if/else Statements

### The `if/else` Statement

- JavaScript. This is how your `if/else` code should look.

### What's a `boolean expression`?

- Which ones are `boolean expressions`?

        (count === 5)
        (name = "fred")
        (3 < 10)
        (10 * 20)
        (6 < 5)
        (true)
        (count = 5)
        (false)
        (Number("12.99"))
        ("Bill" > "bill")
        (1000)

### How does this work?

- If the boolean expressions is `true` then the code after the `if` is run. If it is `false` then the code after the `else` is run.

### Examples

- Here's the above example in running code.

- Here's one that's true

- Where it gets interesting is when we won't know which way it will go until the program is running.

### Full `if/else` Example

- Here's an example: Full Example: Divide Safely

### Guess what's next?

- "History will be kind to me for I intend to write it." - Winston Churchill

- 4.2 Lab 3
- 4.2 Assignment 3