Chapter 6. Controlling Flow with Conditionals and Loops

After reading this chapter, you'll be able to

  • Understand the different types of conditional statements in JavaScript.

  • Use the if else conditional statement to control code execution.

  • Use the switch statement.

  • Understand the different types of loop control structures in JavaScript.

  • Use a while loop and a do…while loop to execute code repeatedly.

  • Use different types of for loops to iterate through ranges of values.

If (and how)

The if statement is used to determine which way to go within a program or which code to execute based on one or more conditions. If you've ever booked a flight on the Internet, you know about making decisions. You might want to go on a quick weekend getaway, for example, so ...

Get JavaScript Step by Step now with O’Reilly online learning.

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