Chapter 3. Conditional Statements
CONDITIONAL STATEMENTS are a type of control flow concerned with logic: they determine when and where to execute code, based on conditions you specify.
if/else STATEMENTS
Conditional statements are almost entirely some variation on âgiven X, do Y.â The most common example of thisâand one nearly ubiquitous in terms of any programming languageâis the if
/else
statement. Saying âif this, do thatâ is about as uncomplicated as a logical statement gets, but by the end of this chapter youâll see how something so simple on the surface can make up the lionâs share of logic in our scripts.
if
In its most ...
Get JavaScript for Web Designers 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.