Rock paper scissors 8 : expected expression got keyword else


#1

expected expression got keyword else. what is the code for lesson 8 rock paper scissors please copy and paste it in reply or at least tell me what is wrong with it. here is my code:
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 === "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 === "Rock") {
return "Rock wins!"
}
else {return "Scissors wins!"}
}
}
}
}


#2

else if(choice1 === "Paper") {
if(choice2 === "Rock") {
return "Paper wins!"
} else {
return "Scissors wins!"
}

You're missing a closing statement at the end of this else if statement.


#3

i meant ALL of the code for the WHOLE thing


#4

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 === "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!"
 } 
//Missing a closing bracket here " } "
else if(choice1 === "Scissors") {
 if(choice2 === "Rock") {
 return "Rock wins!"
 }
 else {return "Scissors wins!"}
 }
 } // Extra Bracket, Delete this
 } // Extra Bracket, Delete this
 } // Extra Bracket, Delete this

#5

THX SO MUCH!!! finally i have been stuck on that, thx dude


#6

When you have a lot of opening and closing brackets like that, go through your code and count all the opening brackets and closing brackets. if the opening brackets and closing brackets are equal then you're good to go, otherwise you need to change some stuff.

{ //1
{ //2
{ //3
} //2
} //1
{ //2
} //1
} //0

That's how I count the open and closing brackets.