# Rock paper scissors

#1

I have posted my code below. Pretty much, I got the parentheses and order of nesting from another question and thought that I understood it. Apparently not.
The second part of my code won't work. Im getting really confused about the logic, even in words, let alone nesting these if/else statements.
When a new comparison is being made, It seems like we should begin with an if statement. and then use" else if." Then else.
Can someone help me understand this? Thanks alot.

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

``````

}```````

#2

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

the above code should look like
else if (choice1==="paper")
{
if (choice2==="rock")
{
return "paper wins."
}
else if(choice2==="scissors" )
{
return "scissors wins."
}

you can use else if statement how-many times you want to use. choice2 is a different comparison which starts with if statement and because here we have condition in else statement , we should use if else instead of else.

#3

Thanks
I will give it a try. I am still having a hard time understanding the basic logic, Javascript aside.