Having an issue with 7. what if choice1 is paper?


#1


https://www.codecademy.com/en/courses/web-beginner-en-WF0CF/3/2?curriculum_id=50579fb998b470000202dc8b

SyntaxError: Unexpected token else


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"
    }
};


#2

Hey @teasdale.st

You have forgotten to put the curly brace for the if statement inside your first else if statement, your else statement should technically fall inside the aforementioned else if statement. Same thing will apply to the second part of your compare function.You must put the curly brace for the if statement, and put the else inside of the else if. Hope this clears things out...


#3

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