What if choice1 is paper? Please help


#1



Hi, I am stuck on Javascript Build 'Rock, Paper, Scissors' 7.What if choice1 is paper?


My code states: 'Oops, try again. There was a problem with your syntax.


function compare(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";
*     }
*   };
* };


The error must be in the last else if section because I passed the previous lesson fine with the code above it.


#2

Take a look at my comment:

else if (choice1 === "rock") {
    if (choice2 === "scissors") {
        return "rock wins";
    } else {
        return "paper wins";
    }
}; // <-- this semicolon terminates whole if statement

It's never a good idea to put a semicolon after closing brace of if, for, while block.


#3

Thankyou for replying!


#4

You're very welcome :slight_smile: