Hello, can you help me find my mistake, please


#1


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

}*/

    if (choice1 === "rock")  {
            if (choice2 === "scissors") {
        return "rock wins";
    } 
    else {
        return "paper wins";
    } 
    if (choice1 === "paper") {
        if (choice2 === "rock") {
            return "paper wins";
        } 
        else if (choice2 === "scissors") {
            return "scissors wins";
        }
        if (choice1 === "paper") {
            if (choice2 === "scissors") {
                return "scissors wins";
            } 
            else if (choice2 === "rock") {
                return "paper wins";
            }
        }
    }
};
compare(userChoice,computerChoice);


#2

You have a syntax error, you are missing one closing curly brace, one of these: }.

If you tidy up your code, indenting, etc. I think that you will soon spot where it belongs.

Also, you have a logic error. You have twice tested for choice1 === "paper" but have not tested at all for choice1 === "scissors".


#3

Thank you very much for your help


#4

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