8. What if choice1 is scissors


#1


OK folks, here my second attempt at improving my code. I restructured the code so it is identical to the example. Even so, I am running into the error message:

Oops, try again. There was a problem with your syntax.
-and-
SyntaxError: Unexpected token else


var userChoice = prompt("Do you choose rock, paper or scissors?");
var computerChoice = Math.random();
if (computerChoice < 0.34) {
	computerChoice = "rock";
} else if(computerChoice <= 0.67) {
	computerChoice = "paper";
} else {
	computerChoice = "scissors";
} console.log("Computer: " + computerChoice);

var compare = function(choice1,choice2)  {
    
    if (choice1 === choice2)  {
        return "The result is a tie!";
    
    }

        else if  ( choice1 === "paper")  { 

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


Can someone please explain what is going on here?
#2

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

Examine this pattern closely (noting the last brace that was added). Repeat it two more times, changing only the values.


#3

var userChoice = prompt("Do you choose rock, paper or scissors?");
var computerChoice = Math.random();
if (computerChoice < 0.34) {
	computerChoice = "rock";
} else if(computerChoice <= 0.67) {
	computerChoice = "paper";
} else {
	computerChoice = "scissors";
} console.log("Computer: " + computerChoice);

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

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

#4

Look closely at the pattern I gave above. Your code is not following that pattern. Every brace must be in each of the three segments containing this pattern.