Help 'ERROR' | What if choice1 is paper?


I'm getting this error : SyntaxError: Unexpected token else. What did I do wrong ?


Which lesson name is this? or include the link for me. :slight_smile:


ok :stuck_out_tongue_winking_eye:


You didn't use open and closing brackets for the if statement on line 16/17


That's not the problem , It said it was right in the previous exercise


I don't know. Your spacing is not great, but all of your braces seem to be in place.


Yeah like before I get confused with c# and I write the curly brackets like I do in c# :stuck_out_tongue_winking_eye: but do you think it is a glitch ?


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";

Try using this, I cleaned up yours.


It works thanks , so my problem is spacing , but in engines like visual studios would this spacing make a difference ?


In python, spacing is HUGE, but in Java, and JavaScript, it mostly isn't. The problem was probably just something like a bracket, but keeping it clean is how to avoid syntax errors.


Yeah , it's just that c# mixes me up with this syntax ;(


Yeah I agree Thanks for your time :slight_smile:


It's okay! I know that happens, it's hard to get used to a new language, keep it up, you're doing good. No problem, glad to help. :slight_smile:

I help you out because of I have time, and I'm not better than anybody else. I just want to represent the community by helping you. If it's something I can help with, I want to. :slight_smile: I appreciate your patience, and it's super cool that you program in C#, I haven't touched it. Have a wonderful day!


Thanks I appreciate it ;p


Thanks so much for wasting your time on my stupid mistake :wink: Yeah c# is confusing if you learn JavaScript too . Have a good day :wink:


I hope I don't bug you again :wink:


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