Also stuck on 8/9 Rock Paper Scissors xD


#1

Hi sorry another one

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

// if they choose paper
else if (choice1 === "paper")
{
if (choice2 === "rock")
{
return "paper wins";
}
else { return "paper wins;
}
}

//if they choose scissors
else (choice1 === "scissors")
{

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

}
}

compare ("userChoice,computerChoice");

Comes up with "SyntaxError: Unexpected token ILLEGAL"
cries help please!


#2

Hi,
I think you missed a opening { after the last else and before the (choice2 === "paper"){.


#3

I guess al least one problem is that else has no condition after it:

else (choice1 === "scissors")

PS: Some hints about formatting. First of all you need only > to get the block look and it will end if you leave a blank line to the next plain text. And more important that is not meant to format code. For code formatting you got the </> icon in the menu bar, you could start a line with 4 spaces (and if necessary a blank line between regular text), you could use these backticks ` for inline formatting or 3 of them at the beginning and end of your code for this nice syntax highlighting of your code or you code use the shortcut CTRL+SHIFT+C to get a textfield where you can enter code which just picks from the previous what is considered fitting. Hope this helps.