presents

Scripting for IXD

Lesson 9: Conditional Structures

Making Decisions in JavaScript

We've been building our set of tools in JavaScript and have focused primarily on data types in the past few modules. Now we make a major shift to look at more utilitarian elements such as structures.

Our first structures to investigate will be the conditional structures. By now you've considered how decisions impact a script through your flow chart exercises. Adding conditional structures in our JavaScript

Read Duckett, Chapter 4, pp.160-169.

While this is only a few pages it is loaded with details we'll use throughout the rest of the course. As you probably found in your flow charts, decisions are often crucial to successful scripting.

Study Questions

  1. SKILL: Create conditional blocks using if and else.
  2. SKILL: Create conditional blocks using switch.
  3. What is the difference between if... else statements and switch statements?
  4. What is type coercion?
  5. What does it mean that a value is "truthy" or "falsy"?
  6. What is the difference between the == and === or between != and !==?

Presentation and Demo

Watch this presentation and play along in the demo provided in CULearn. Use this handout to take notes.