7/9 rock paper scissors help please


#1



I am stuck at 7/9, what is wrong with the syntax?


The only one I saw is a syntax error, but there could be more.


Replace this line with your code. 
var compare = function(choice1, choice2) {
    if(choice1 === choice2) {
        return "The result is a tie!";
    } else if (choice2 === "scissors") {
        return "rock wins"; 
    } else {
        return "paper wins";
    }
    else if(choice1 === "paper"
    {
        if (choice2 === "rock")
        {
            return "paper wins";
        }
        else 
        {
            return "scissors wins!";
        }
};
compare(userChoice,computerChoice)


#2

Hello @jonah125,

  1. Javascript doesn't recognise indentation, unlike Python. In Javascript, indentation is used to make the code more readable.
  2. So in your case, your else if (choice2 === "scissors") statement and your else statements are misplaced. You should delete those, and move straight on to your else if(choice === "paper") clause, and remember to add the closing bracket in.
  3. Also, you haven't closed your else if clause with a closing curly brace...

Hope this fixes your problems...


#3

Oh yes, thank you very much. I'm quite new to coding!


#4

A post was split to a new topic: What is wrong here?