Break Statement: To Break The Loop Permanently if certain condition is true.
Example:
<body>
<script>
// Break in For Loop
t=9;
for(i=1; i<=12; i++)
{
if(i==6)
break;
document.write("<br/>" + t+ " X " + i + " = " + i*t);
}
</script>
</body>
Output:
9 X 1 = 9
9 X 2 = 18
9 X 3 = 27
9 X 4 = 36
9 X 5 = 45
Example:
<body>
<script>
// Break in For Loop
t=9;
for(i=1; i<=12; i++)
{
if(i==6)
break;
document.write("<br/>" + t+ " X " + i + " = " + i*t);
}
</script>
</body>
Output:
9 X 1 = 9
9 X 2 = 18
9 X 3 = 27
9 X 4 = 36
9 X 5 = 45
No comments:
Post a Comment