SyntaxError: Expected ';'


#1

This is driving me insane...what am I missing? :confounded:

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

#2

All of your returns in the second half are missing semicolons.


#3

Thanks for pointing that out! I tried the following to no avail....

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 (choice1 === 'scissors') {

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

#4

What error does it give you?


#5

Same error :confused:


#6

I checked it in a code validator, and realized that you have an unneeded condition in your else-statement.


#7

That's weird....it passed the previous challenges. Only when I got to this last part with paper as choice1, it started giving me grief.


#8

That is the else that you used a condition. :slightly_smiling:


#9

Wow, I'm outta gas and feeling really dense...I finally got it. Thank you!!


#10

Welcome! :slightly_smiling: