7/9 please help


#1

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

I don't know what my problem is can anybody help me fix this


#2

you forgot the { at the start of the else if statement and "sissors" should be spelt scissors instead if this no work contact me


#3

your missing a } before the second else if and 2 } at the end for the second else if and the function.


#4

SyntaxError: Unexpected token else

it gives me this now


#5

can you post your semi-fixed code please?


#6

/*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"
}


#7

you need a extra } on the end i think if that does not work then i will examine it further...


#8

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

}

this is the full correct code