8. What if choice1 is scissors? Need help!


#1


https://www.codecademy.com/courses/javascript-beginner-en-Bthev-mskY8/1/4?curriculum_id=506324b3a7dffd00020bf661


I can't figure out what I've done wrong in my code, can anyone help? I'm sure it's just something small that I have forgot to include. I've been stuck on this for the past couple of days so any help would be appreciated!


var compare = function(choice1, choice2) {
    if(choice1 === choice2) { 
        return "The result is a tie!";
    }
    else if(choice1 === "rock") {
        if(choice2 === "scissors") {
            return "rock wins";
        }
        else {
            return "paper wins"; 
        }
}
    else if(choice1 === "paper") {
    if(choice2 === "rock") {
        return "paper wins";
        }
    else {
        return "scissors wins"; 
    }
    }
};
    else if(choice1 === "scissors") {
         if(choice2 === "paper") {
            return "scissors wins";
        }
        else {
            return "rock";
        }
        }
};
compare(userChoice, computerChoice);


#2

It looks like you have a closing bracket before your last else if that shouldn't be there.


#3

Thank you! I always end up doing something wrong when placing brackets.


#4

If you feel like you have an error like that go to labs repl.it and run your code in the javascript lab. It does a pretty good job catching those errors and letting you know.


#5

Thank you! I appreciate your help!


#6

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.