If username as "admin", then prompt a password, if the input is empty, “Canceled.”, if it’s another string – then show “I don’t know you”.
The password is checked as follows:
- If it equals “sacredpass”, then show “Welcome!”,
- Another string – show “Wrong password”,
- For an empty string or cancelled input, show “Canceled.”
let loginName = prompt('your login name', '');
if (loginName == 'admin') {
let password = prompt('password','')
if (password == 'sacredpass') {
alert('Welcome');
} else if (password == '' || password == null) {
alert('canceled');
} else {
alert('Wrong password')
}
} else if (loginName == '') {
alert('canceled')
}
else {
alert('Dont know you')
}