A while loop would be much better than a recursive function:
Code:
while (true) {
var user_name = prompt("Please enter your username: ");
var password = prompt("Please enter your password: ");
if (user_name == "John123" && password == "helloworld") {
alert("Welcome, " + user_name + ".");
break;
}
else {
alert("Sorry, information invalid.");
}
}
This is however a very bad way of coding since it will completely lock the page until the information is correct! You should really use a form with inputs for name and password instead of using prompts.
Bookmarks