Loops: Example-2

Here is another loop exampe that will only stop when the user enters:

	<!DOCTTYPE html> 
<!--Example 1: Loop2.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
while (answer != password) //begining of the while loop
answer = window.prompt("Please enter your answer");
} //end of while
document.writeln('<h2>Congrats! your password is right. <h2>');
// -->
See here a demo where Loop until the right entry:

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