Let’s first look at an example:
There are several concepts that we should know. First of all, var x= is a variable declaration. If you want to create a variable, you must declare the variable using the var statement. x will get the result, namely, true or false. Then we use a condition statement if else to give the script the ability to choose between two paths, depending on this result (condition for the following action). If the result is true (the user clicked “ok”), “Thank you” appears in the window box. If the result is false (the user clicked “cancel”), “Good choice” appears in the window box instead.
We can make more complex message boxes using var, if and those basic methods.
Next Up: Function