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
- SKILL: Create conditional blocks using
if
andelse
. - SKILL: Create conditional blocks using
switch
. - What is the difference between
if... else
statements and switch statements? - What is type coercion?
- What does it mean that a value is "truthy" or "falsy"?
- 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.