From 03956736506db3d33a96ec7df188fec9473e632a Mon Sep 17 00:00:00 2001 From: Anmol Sethi Date: Thu, 17 Aug 2017 21:28:37 -0400 Subject: [PATCH] Safari does not return an empty string when a prompt is cancelled title --- .../10-ifelse/4-check-login/solution.md | 12 +++--------- 1 file changed, 3 insertions(+), 9 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 20abeb43..cfe52074 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,23 +9,17 @@ if (userName == 'Admin') { if (pass == 'TheMaster') { alert( 'Welcome!' ); - } else if (pass == null || pass == '') { // (*) + } else if (pass == null) { alert( 'Canceled.' ); } else { alert( 'Wrong password' ); } -} else if (userName == null || userName == '') { // (**) - +} else if (userName == null) { alert( 'Canceled' ); - } else { - alert( "I don't know you" ); - } ``` -Please note the `if` check in lines `(*)` and `(**)`. Every browser except Safari returns `null` when the input is canceled, and Safari returns an empty string. So we must treat them same for compatibility. - -Also note the vertical indents inside the `if` blocks. They are technically not required, but make the code more readable. +Note the vertical indents inside the `if` blocks. They are technically not required, but make the code more readable.