Choice 1 rock, unexpected token else


#1

Hey guys, I can't seem to find what's wrong with this code, but I keep getting "Syntax error: unexpected token else". Could you help me out?

/*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 === "scissors");
       { return "rock wins"}
    else
       { return "paper wins"}
    };
    compare (2, 2)

#2

HI this line remove the ; at the end

if(choice1===choice2); <-- this one

and this part you should add one } for closing the compare function

var compare = function (choice1, choice2) {
   ....
    else
       { return "paper wins"}
    };
} <-- add thos one

And this line line remove it it

compare (2, 2)

you can't call it now..


#3

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