From 6410140c37103f17ae4f119b5dfd3cfe754ef07e Mon Sep 17 00:00:00 2001 From: snakecase <4579891+snakecase@users.noreply.github.com> Date: Sun, 11 Mar 2018 10:44:54 +0500 Subject: [PATCH] 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. --- 1-js/02-first-steps/10-ifelse/4-check-login/solution.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/1-js/02-first-steps/10-ifelse/4-check-login/solution.md b/1-js/02-first-steps/10-ifelse/4-check-login/solution.md index cfe52074..b535650e 100644 --- a/1-js/02-first-steps/10-ifelse/4-check-login/solution.md +++ b/1-js/02-first-steps/10-ifelse/4-check-login/solution.md @@ -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" );