There are actually two different if..else constructs. The first is a simple if-else:
if ( condition ) { // Do stuff if condition is true } else { // Do stuff if condition is not true }
The following is if-else-if:
if ( condition ) { // Do stuff if condition is true } else if ( differentCondition ) { // Do stuff if differentCondition is true } else { // Do stuff if neither condition nor differentCondition is true }
You can also use else-if as many times as you want, for example:
if ( condition ) { // Do stuff } else if ( condition2 ) { // etc } else if ( condition3 ) { // etc } else if ( condition4 ) { // etc } else { // etc }
And each if ifelel part is optional, except for the initial if block. Therefore, if you do not want to do anything if the condition not true, you can simply completely exclude the else block:
if ( condition ) { // do stuff if condition is true }
NTN
Having gone beyond your question for a moment, the expression evaluated in your if condition is a little wibbly-wobbly.
willOrderPackage will always be true or false , but it is important to note that true and "true" or false and "false" are different. The first is logical, the second is a string.
So your if statement should ask:
if ( willOrderPackage == true ) {
Even better, when you evaluate an expression in an if statement, it means == true at the end of it, which is invisible. For instance:
if ( willOrderPackage == true ) {
will be interpreted as:
if ( (willOrderPackage == true) == true )
The advantage of this is that you can actually omit the entire == true bit from your code so you can simply write:
if ( willOrderPackage ) {
And effectively you still say "if willOrderPackage is true"
Hope that helps you sort out a few things!