mardi 30 octobre 2018

Having issues combining two var into one if statement

Just getting started with coding and having trouble visualizing how to write this code:

var userAge = prompt("Are you old enough to vote? Lets check, enter your age.","");
        var citizen = prompt("Are you a US citizen? Y or N","");

        if(citizen = y && userAge >= 18)  
        {
            alert("Congrats, you can vote!");
        }else
        {
            alert("Sorry you can vote just yet");
        }

        document.write("<br/>");

        if(citizen = n && userAge < 18)
        {
            document.write("but at least you have your youth");

        }else if (citizen = y && userAge > 18)

            {
            document.write("You should be registered to vote! If not, visit www.usa.gov/register-to-vote");
            }

Any insights? Thanks for your time and support.

Aucun commentaire:

Enregistrer un commentaire