O'Reilly logo

JavaScript Step by Step by Steve Suehring

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter 6. Controlling flow with conditionals and loops

After completing this chapter, you will 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 evaluates an expression and, based on the results, determines which code, if any, executes within a program. More complex if statements can control which code executes based on multiple conditions. If you’ve booked a flight on the Internet, you know about ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required