Chapter 18. Controlling Flow with Conditions and Loops

What You’ll Learn in This Chapter:

How to test conditions with the if statement

How to use comparison 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 and do...while loops

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

How to escape from loops and continue loops

How to loop through an array’s properties

Statements in a JavaScript program generally execute in the order in which they appear, one after the other. Because this order isn’t ...

Get HTML, CSS and JavaScript All in One, Sams Teach Yourself: Covering HTML5, CSS3, and jQuery, 2nd 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.