Break Statement

The statement stops the loop immediately. This statement along with the do ... while loop are shown in this example:
	<!DOCTTYPE html> 
<!--Loop4.html -->
<title> Loop until the right entry </title>
<script >
var password = "pass the test" //The value that will make the loop stop var answer; //the answer entered by the user
var counter = 1; //counter
do {
answer = prompt("Please enter your answer");
if (counter == 5) {
counter++; }
} while (answer != password);
if (answer == password)
document.writeln('<h2>Congrats! your password is right. <h2>');
document.writeln('<h2>Sorry! your password is wrong after 5 attempts. <h2>');
// -->

For more details, please contact me here.
Date of last modification: March 26, 2019.