Get Even More Visitors To Your Blog, Upgrade To A Business Listing >>

JavaScript: break statement

Tags: number input
We already saw the use of break in switch case. Similarly, break is used in while, do-while and for loops to come out of a loop.


while loop

var number = parseInt(prompt("Enter a number less than 100", "10"));


Even numbers from 0 to "

+ number + " are ");

var i = 0;

while (i number) {
if (number >= 100) {
document.write("Input should be );
document.write(i + "
i += 2;

Load above page in browser, it prompt for input, if you enter a number which is >=100, it prints the message "Input should be

Previous                                                 Next                                                 Home

This post first appeared on Java Tutorial : Blog To Learn Java Programming, please read the originial post: here

Share the post

JavaScript: break statement


Subscribe to Java Tutorial : Blog To Learn Java Programming

Get updates delivered right to your inbox!

Thank you for your subscription