dimanche 10 janvier 2021

Trying to solve accumulator pattern, "If neither of the previous conditions was true, do this" How can I fix it?

I'm working on an exercise that asks a user their birthyear and then depending on the year they enter, gives one of two alerts. "You are in Gen Z" or "You are a millennial", and then if neither of those statements are true, alerts "you inched by" and then the amount.

I've been working on this for awhile now and have really done my best, but I am stuck. I'm a beginner, so please bear with me.

The first two alerts are working when the year is entered, I just can't seem to get the "you inched by" part figured out. What am I doing wrong? Here is the code:

        var birthYear= prompt("What year were you born?");

        if (birthYear > 1997 || birthYear > 2020) {
            alert("You are in Gen Z")

        } else if (birthYear < 1997 || birthYear > 1980) {
            alert("You are a millennial")

        } else  (birthYear === 1995); {
            alert("you inched by")
        };

// If neither of the previous conditions was true (birthYear === 1995) we alert "You inched by!"

Aucun commentaire:

Enregistrer un commentaire