6. what if choice 1 is rock 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 === "scissors") {
    return "rock wins";
    }
    else {
    return "paper wins";
}
}
}

there's my code it says,
"Syntax Error : Unexpected Token else"


#3

and when I get rid of:

the else there, it says
"Syntax Error: Invalid End Of Input"


#4

Remove the semi-colon from ); {


#5

Oi! I figured it out, but now the same exact thing is happening on 7. if first choice is paper! no semicolon though


#6

Go ahead and repost your code, please.


#7

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

still
"Syntax Error: Unexpected Token else"


#8

Move the third brace to the bottom (so it closes the function).


#9

does not work still:disappointed:


#10

Short of giving the solution, there is not much to suggest. I spotted one reason for syntax error. What error are you getting now? Post your repaired code, please.


#11

/*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";
}
}
}                               // << remove this }
else if(choice1 === "paper") {
    if(choice2 === "rock") {
       return "paper wins";
}
    else {
       return "scissors wins";
}
}
}                               // << add a ; here

"Syntax Error: Unexpected Token else"


#12

and:
OOPS! try again there was a problem with your syntax