here.” Words are used as placeholders, and their meaning is clear from context. For
example,
statement1
and
statement2
represent two different statements,
expression
is something that results in a value, and
condition
refers to an expres‐
sion that is treated as truthy or falsy.
Remember that a block statement is a statement…so wherever you
can use a statement, you can use a block statement.
Because we’re already familiar with some control flow statements, let’s see their
metasyntax:
while statement
while(condition)
statement
While
condition
is truthy,
statement
will be executed.
if...else statement
if(condition)
statement1
[else
statement2]
If
condition
is truthy,
statement1
will be executed; otherwise,
statement2
will be
executed (assuming the
else
part is present).
do...while statement
do
statement
while(condition);
statement
is executed at least once, and is repeatedly executed as long as
condition
is truthy.
for statement
for([initialization]; [condition]; [final-expression])
statement
Before the loop runs,
initialization
is executed. As long as
condition
is true,
statement
is executed, then
final-expression
is executed before testing
condition
again.
70 | Chapter 4: Control Flow