The break Statement
The break statement will break the loop and continue executing the code that follows after the loop (if any).
Example
for (i=0;i<10;i++)
{
if (i==3)
{
break;
}
x=x + "The number is " + i + "<br />";
}
{
if (i==3)
{
break;
}
x=x + "The number is " + i + "<br />";
}
Try it yourself »
The continue Statement
The continue statement will break the current iteration and continue the loop with the next value.
Example
for (i=0;i<=10;i++)
{
if (i==3)
{
continue;
}
x=x + "The number is " + i + "<br />";
}
{
if (i==3)
{
continue;
}
x=x + "The number is " + i + "<br />";
}
Try it yourself »
No comments:
Post a Comment