October 2008
Beginner to intermediate
544 pages
13h 21m
English
Conditionals break down into three parts: the if section, where we do our test; the then section, where we put the part of the script we want to do if the result is true; and an optional else section, which contains the part of the script we want to have happen if the result of the test is not true. The contents of what we’re testing in the if section are in parentheses, and the contents of the other two sections are each contained in braces.
To confirm a choice:
1. | if (confirm("Are you sure you want to do that?")) { |
2. | alert("You said yes"); |
Read now
Unlock full access