Rock, paper, scissors


#1


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


I keep getting SyntaxError. I've started this exercise over a few times and I haven't been able to go further. This is the error that I'm receiving now. Thanks in advance. Unexpected token {


var userChoice = prompt("Do you choose rock, paper or scissors?");
var computerChoice = Math.random();
if (computerChoice < 0.34) {
	console.log("rock");
} else if(computerChoice <= 0.67) {
	console.log("paper");
} else {
	console.log("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";
                
            }
};


#2

missing a closing parentheses in the last if statement


#3

in the last if statement there is a couple of syntax errors with the curly brackets


#4

Thanks. That worked.


#5

Thanks. That worked perfectly.


#6

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