Build "Rock, Paper, Scissors"


#1

Here is my code, it says i have a problem with my syntax, but i cant find what it is, if someone can see whats wrong or what does the code needs it will be great, leave my code below:

/*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!";
                }
                if (choice2==="scissors"){
                return "Rock Wins";
                } else {return "Paper Wins";}
                
                else if (choice1==="paper"){
                if(choice2==="rock"){
                     return "paper wins";
                     } else{ return "scissors wins";}
                }
        
                
    }

#2

here seems to be something missing. Also you lack a } to close the function. Maybe have a look at the hint of 6/9 for an example how an else if case in this structure should look like.


#3

Im seeing all lacks closed up, this is the way it should be
if (condition) {
// do something
}
else if (condition) {
if (condition) {
// do something
}
else {
// do something else
}
}
i think mine is pretty similar to this one, also i tried the lack missing. I still cant go on trought this


#4

Could you post the updated code?


#5

This is my code,the error it shows me says that somethings wrong with the syntax
var compare =function(choice1,choice2){
if(choice1===choice2)
{
return "The result is a tie!";
}
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 end

} //functions end