var login = prompt('Введите логин !'); if (login == 'Admin' || 'User'){ var password = prompt('Введите пароль !'); if (password == '12345'){ alert("Добро пожаловать"); } else if (password == null){ alert("Вы уже уходите?"); } else{ alert("Go away"); } } else{ alert("Who are you?"); } Why in the login field when I enter any digits and letters, it goes to the password entry field and does not display "Go away." : If the login is "Admin" or "User", then it displays a field for entering a password. If something else then "Go away"
login == 'Admin' || 'User'login == 'Admin' || 'User'equivalent to the condition(login == 'Admin') || 'User'(login == 'Admin') || 'User', which is equivalent to(login == 'Admin') || true(login == 'Admin') || true, which is equivalent to(true || false) || true(true || false) || true, which is equivalent totrue. - Yaant