let username = prompt('Enter the username','');
if (username.toLowerCase()=='admin') {
let password = prompt('Enter the password','');
if (password.toLowerCase()=='themaster'){
alert('Welcome!');
} else if (password=='' || password == null) {
alert('Cancelled');
} else {
alert('Wrong Password!');
}
} else if (username=='' || username == null) {
alert('Canceled!');
} else {
alert('I don\'t know you!');
}
Here I wish to show "Cancelled", if a person press "Escape". So I have given the condition that if a user leaves the field empty OR press escape (which returns null), it should show cancelled. But its not showing "Cancelled" in case of pressing "Escape" button. But when i remove the ".toLowerCase()" method, then it works. Can someone explain .. Why ?