8. JavaScript: Control Statements II

Who can control his fate?

—William Shakespeare

Not everything that can be counted counts, and not every thing that counts can be counted.

—Albert Einstein

Objectives

In this chapter you’ll:

• Learn the essentials of counter-controlled repetition

• Use the for and do...while repetition statements to execute statements in a program repeatedly.

• Perform multiple selection using the switch selection statement.

• Use the break and continue program-control statements

• Use the logical operators to make decisions.

Outline

8.1 Introduction

8.2 Essentials of Counter-Controlled Repetition

8.3 for Repetition Statement

8.4 Examples Using the for Statement

8.5 switch Multiple-Selection Statement

8.6 do...while Repetition ...

Get Internet & World Wide Web: How to Program, Fifth Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.