Chapter 6

Getting into the Flow with Loops and Branches

In This Chapter

arrow Finding out about if/else branching

arrow Understanding the different types of loops

arrow Using loops to repeat statements

arrow Looping through the values of an array

“It's not hard to make decisions when you know what your values are.”

— Roy Disney

In earlier chapters of this book, we generally talk about and demonstrate linear JavaScript code. However, more often than not, there comes a time (many times, actually) in a program where you need a choice to be made or where you need to alter the straight-ahead logic of a program to repeat statements multiple times with different values. In this chapter, we discuss looping and branching statements.

ontheweb Don’t forget to visit the website to check out the online exercises relevant to this chapter!

Branching Out

Looping and branching statements are called control statements because they control the order in which JavaScript programs are run. You can use branching statements ...

Get Coding with JavaScript For Dummies now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.