If statements

From CodeStuff
Revision as of 05:52, 16 April 2015 by 121.74.237.41 (Talk)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

You can use if statements to optionally run a piece of code.

The if statement takes the form

if (condition) {
 actions;
}


You can optionally provide code to be run when the condition is not true with else.

if (condition) {
  things to do when the condition is true
} else {
  otherwise do the things here
}


In the example Below, the circle is filled when the mouse pointer is inside it.