I'm stuck on what if choice1 is paper?


#1


I'm stuck at 7. what if choice is paper?

sometimes it says "syntax error", other times it says "unexpected token else"
I don't know what I'm doing wrong, if someone could write it up correctly and respond with it I'd get it. Thank you so much!


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


#2

You always need an open bracket before your return statements and after your conditions. I'm 100% certain you went through this if/else syntax many times in previous lessons.
eg

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

Same goes for your else statement

else {
   return "scissors wins"
}

Please also make sure you have the right amount of closing curly brackets for your opening brackets. They are pairs.


#3

Thank you. I can't believe I missed something so obvious face palm thanks again.


#4

It's fine. Syntax can be easily forgotten if you didn't touch it for long. And no problem! Have fun coding :slight_smile:


#5

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