9.5 Game Night Web Page
In the previous section, we examined an if statement with a mathematical-expression condition that asked whether the user’s age is greater than 16 (age > 16). For a condition to work, it has to evaluate to true or false. The age > 16 condition does indeed evaluate to true or false, with the result depending on age’s value. In this section, we examine a web page with an if statement where the condition again evaluates to true or false, but this time, it might not be as obvious that the condition evaluates to true or false. This time, we use the confirm method call (introduced two sections earlier) for the if statement’s condition.
Take a look at the Game Night web page in FIGURE 9.6. When the user clicks the button, ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access