Skip to content
Advertisement

firebase auth.currentUser.email error/bug?

clearly (jimmy22@mail.com === “benjamin@icloud.com” || “lame@mail.com”) should return false

so why is it printing “email in first : jimmy22@mail.com”

when it should print “email was : jimmy22@mail.com”

code below

let email = auth.currentUser.email


if(email === "benjamin@icloud.com" || "lame@mail.com") {
    alert("email in first : " + auth.currentUser.email )
    checkUserIsNotAlreadyInGame() 
    return
        } else {
            alert("email was :" + auth.currentUser.email )
            return
        }

prints “email in first : jimmy22@mail.com”

Advertisement

Answer

your expression will always evaluate to true because it falls to the “lame@mail.com” string which always evaluates to true in the condition.

change your condition to the following:

if(email === "benjamin@icloud.com" || email === "lame@mail.com")

then you’d get the expected result

User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement