Build "Rock, Paper, Scissors game" The end


#1



Hello, I don't know what I have got wrong! Can anyone help?

https://www.codecademy.com/en/courses/javascript-beginner-en-Bthev-mskY8/1/5?curriculum_id=506324b3a7dffd00020bf661


SyntaxError: Unexpected token {


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 win"
        }
    }else(choice1 === "scissors"){
        if(choice2 === "paper"){
            return "scissors win"
        }else(choice2 === "rock"){
            return "rock wins"
        }
    }
};
compare(userChoice,computerChoice)


#2

HI this part should also begin with a else if statement

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

Even if it the last one in this lesson your are making a if , else if, else if and else if wihout else statement and remenber that the else statement doesn't take any condtion

else if (condition) {
   if (condition) }{ 
 
   }
   else  {

   }
}

#3

Hey, I changed the else to an else if statement, but it is still unexpected token {.
...
else if(choice1 === "scissors"){
if(choice2 === "paper"){
return "scissors win"
}else(choice2 === "rock"){
return "rock wins"
}
}
The marked { is the one that is unexpected


#4

The else statement shouldn't have teh condtion

....
    else(choice2 === "rock"){
       return "rock wins"
    }
}

#5

I got it! :smiley: Thank you so much!!! I'm so dumb...