6/9 i still dont know what is wrong with my syntax


#1
if (choice1 === choice2) {
    return "The result is a tie!";
}; 
else if (choice1 === "rock") {
    if (choice2 === "scissors") {
        return "rock wins";
    };
    else {
        return "paper wins"
    };
};    
};

what is wrong?


#2

I think you used too much ; and { }.

try writing these...


#3

Sorry, I still don't understand. Could you type and explain it, please.


#4

This is what I typed. :smile:

I'm new to these stuff, you'll just get confuse if I explained why I typed that.


#5

no sorry I mean like copy and paste it. I get really confused with just pictures


#6

you are using too many ; symbols. Let's take a closer look at what you wrote:

if (choice1 === choice2) {
    return "The result is a tie!";  ///this is the correct place for the ; symbol
};  /// you don't need one here
else if (choice1 === "rock") {
    if (choice2 === "scissors") {
        return "rock wins"; ///one again this is in the right place
    }; ///but this one shouldn't be here
    else {
        return "paper wins" ///you SHOULD have a ; at the end of this line
    }; ///but this one is not needed
};    /// and this one is not needed 
};  /// this one is fine for closing the function

What I'm trying to get across is that you only need a ; symbol when you tell the program to do something, or after you declare something.

for example after declaring a variable is a good place or when you console.log(), return a statement, or at the end of a function but not every line of code needs one.

so your code should look something like this:

    if (choice1 === choice2) {
        return "The result is a tie!";
    } ///closes the if
    else if (choice1 === "rock") {
        if (choice2 === "scissors") {
            return "rock wins";
        } ///closes the if
        else {
            return "paper wins";
        } /// closes the else
    } /// closes the else if
}; /// closes the function.

I hope this has helped and good luck