<!DOCTTYPE html>
<!--Loop4.html -->
<html>
<head>
<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) {
break;
counter++; }
} while (answer != password);
if (answer == password)
document.writeln('<h2>Congrats! your password is right. <h2>');
else
document.writeln('<h2>Sorry! your password is wrong after 5 attempts. <h2>');
// -->
</script>
</head>
<body></body>
</html>