#7 Help needed


Hi friends.

Disappointed with myself. I have followed the instructions and check some post in this forum but I still doing something wrong.

Someone can help?
Code and error's messages copied below.



Oops, try again. There was a problem with your syntax.

SyntaxError: Unexpected token else

/*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 (computerChoice, userChoice) {
    if (computerChoice === userChoice) {
    return "The result is a tie!";
    else if(computerChoice === "rock") {
        if (userChoice === "scissors") {
        return "rock wins";}
        return "paper wins";}
    else if(computerChoice === "paper"){
        if (userChoice === "rock"){
        return "paper wins";}
        return "scissors wins";}


The 2 curly brackets before your else aren't needed here. Also, be sure to close your compare function with the correct syntax.


Thanks, thanks, thanks!!!

Actualy I had 3 curly brackets not needed in my code.

Do you know links with sintax lessons for beginners? I "need" more background to understand the basic sintaxis rules.

Thanks again for your help biff75


Anytime :slight_smile:

Try going over this:


I learned a lot by reading answers to posts on this forum though.


Thanks again biff :slight_smile:

You are very helpful. Looks like a very interesting guide..


This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.