[Solved] I am trying to make a login screen with javascript but it does not load when open the page


There is so much wrong with your code, this should work though.

What you got wrong is:

  • You cannot set variables using the - operator
  • You cannot compare in an if-statement using single =
  • You cannot name variables with numbers.
var unc = false; // username correct
var pwc = false; // password correct

while (!login());

function login() {

    var username = prompt("Username");
    var password = prompt("Password");

    if (username == "wouterXD") {
        unc = true;
    } else {
        unc = false;
    }

    if (password == "Wout2003!") {
        pwc = true;
    } else {
        pwc = false;
    }

    if (unc && pwc){
        return true;
    } else {
        return false;
    }
};

3

solved I am trying to make a login screen with javascript but it does not load when open the page