simple example.
var ask = prompt("enter your login"); while (ask != "Admin") { ask = prompt("enter your login"); console.log(ask != "Admin"); // true }; if (ask == "Admin") { alert("Hello, Admin"); } I deliberately enter not "Admin" enters the cycle 1 time and if you enter not "Admin", leaves the cycle, although it should loop, until you enter "Admin"