Using the break statement:
Break statement allows you to break or exit a loop. When used inside a loop, the break statement stops executing the loop and causes the loop to be immediately exited. If the loop has statements after the break statement, the statements do not execute.
Demo:
- Let’s create a document called breakStatement.html.
- Write the following code:
- Execute the script by opening the file in the web browser. If you are using Internet Explore click on “Allow Blocked Content” to allow the script to execute and if you are using Mozilla Firefox then click on allow “ActiveX Controls”.
Thanks for reading the blog.