| Applying science to business management |
  
continue
The continue statement is similar to break in that it terminates
execution of a part of a loop. However, unlike break, continue only skips
execution of the remaining steps in the current iteration instead
of terminating the entire loop.
For example, the following code adds all positive numbers in list:
var total=0,n;
for(n=0; list[n]!=null; n++) {
if(list[n]<0)
continue;
total+=list[n];
}
This example is exactly like the first example using break, except that continue
is substituted for break. In
this example, each time you encounter a negative number, the
remaining steps in the current loop are skipped. Since there is
only one remaining step in the statement block, total+=list[n];, the loop is
effectively just summing positive list elements.
|