Chapter 18. Controlling Flow with Conditions and Loops

WHAT YOU’LL LEARN IN THIS CHAPTER:

• How to test variables with the if statement

• How to use various operators to compare values

• How to use logical operators to combine conditions

• How to use alternative conditions with else

• How to create expressions with conditional operators

• How to test for multiple conditions

• How to perform repeated statements with the for loop

• How to use while for a different type of loop

• How to use do...while loops

• How to create infinite loops (and why you shouldn’t)

• How to escape from loops and continuing loops

• How to loop through an array’s properties

Statements in a JavaScript program generally execute in the order in which they appear, one ...

Get Sams Teach Yourself HTML, CSS and JavaScript All in One now with O’Reilly online learning.

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