Home Articles FAQs XREF Games Software Instant Books About Feedback Search Site-Map
irt.org logo

Q675 How do you get out of a loop once a certain condition is met?

irt.org | Knowledge Base | JavaScript | Misc | Q675 [ previous next ]

Q675 How do you get out of a loop once a certain condition is met?

By using break; as in:

<SCRIPT LANGUAGE="JavaScript"><!--
for (var i=0;i<10;i++) {
    if (i == 5)
        break;
    document.write(i);
}
//--></SCRIPT>

Provide feedback ...
AddThis Social Bookmark Button

Provide feedback ... AddThis Social Bookmark Button


Last Updated: 30th March 2008. Maintained by: Martin Webb and Michel Plungjan
irt.org liability, trademark, document use, privacy statement and software licensing rules apply.
Copyright © 1996-2008 irt.org, All Rights Reserved.