January 2018
Intermediate to advanced
678 pages
20h 16m
English
if Statement: if by itselfIn the previous section, we didn’t do much with the confirm method call’s returned value—we simply displayed it. That’s OK, but rather unusual. Usually, you’ll use the confirm method call’s returned value of true or false as the criterion for making a decision. If the user clicks OK (for yes), then you’ll do one thing, or if the user clicks Cancel (for no), then you’ll do something else. The easiest way to implement that logic is with an if statement.
Let’s jump right into an if statement example. In the next section, you’ll see an if statement that uses a confirm method call, but for our first example, let’s keep things simple. Here’s an if statement that checks a person’s age and displays a message ...
Read now
Unlock full access