vendredi 18 août 2017

Why doesn't this form code work? It seems logical

I'm trying to program a simple form that asks, mood, age, and gender. It does not matter what I put in the mood prompt it always comes out positive. For the age, I would like the tab to close if they're under 18. And gender, same problem with the mood. Please help. New and trying to learn.

var userMood = prompt("Hey! How's it going?");
        if (userMood = "good" || "Good") {
                alert("Awesome! We just need you to fill out a form for security reasons.");
        } else if (userMood != "good" || "Good") {
                alert("Oh, I'm sorry to hear that... We just need you to fill out a form for security reasons.");
}

var userAge = prompt("What is your current age?");
        if (userAge >= "18" ) {
                alert("Great! You are the sufficient age to enter this webpage!");
                userAge = true;
        } else if ( userAge <= "17"){
                alert("Sorry, you are too young to view this content...");
                window.close();
}
var userGender = prompt ("What is your gender?");
        if (userGender = "male" || "Male" || "female" || "Female"){
                alert("Great! You're human!");
                userGender = true;
        } else {
                alert("The webpage has perdicted non-human cyber activity, you can no longer continue.");
                window.close();
        }

Aucun commentaire:

Enregistrer un commentaire