Fix check for an empty input or ESC key press

According to the task both of these should give an alert('Canceled'). Previous solution implied that both empty input and ESC key return null, but in Chrome 64.0.3282.186 an empty input returns '' instead of null. So we are adding an additional check.
This commit is contained in:
snakecase 2018-03-11 10:44:54 +05:00 committed by GitHub
parent 9365275467
commit 6410140c37
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -9,13 +9,13 @@ if (userName == 'Admin') {
if (pass == 'TheMaster') {
alert( 'Welcome!' );
} else if (pass == null) {
} else if (pass == '' || pass == null) {
alert( 'Canceled.' );
} else {
alert( 'Wrong password' );
}
} else if (userName == null) {
} else if (userName == '' || userName == null) {
alert( 'Canceled' );
} else {
alert( "I don't know you" );