What if choice1 is paper?


#1

this is my code, please help me:

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 if (choice1 === "rock"){
if (choice2 === "paper"){
return "paper wins"
}
else {
return "scisors wins"
}
}

}


What if choice1 is paper? I see nothing wrong with my code. please help!
#2

Hi this part you didn't open the if statement

else if (choice1 === "rock") {
    if (choice2 === "scissors") { <= add one here
        return "rock wins"
    } 
    else {
        return "paper wins"
    }
}

#3

please help! here is my code:
/*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";
}

}
it says "SyntaxError: Unexpected Token else"


#4

Hi this part you close the compare function earlier..... all your else if statement should be inside the the function compare

else if(choice1 === "rock") {
    if(choice2 === "scissors") {
        return "rock wins";
    }
    else {
        return "paper wins";
    }
}
}<== remove this one

and here you should add the closing } of the compare function

else if(choice1 === "paper") {
    if(choice2 === "rock") {
        return "paper wins";
    } 
    else {
        return "scissors wins";
    }
}
}<== add one here

#5

Thank you soooooo much I have been stuck on that for a month and a half or so! It's weird, the problem was with something it already "Ok-ed" Thanks again!