Build "Rock, Paper, Scissors" Next Steps of


#1

Hello friends,
I am strucked with the next steps exercise of Build Rock,Paper,Scissors exercise where we need to include different scenarios as below. I have no clue of whats'wrong with the syntax as it says. SyntaxError: missing ) after argument list. Please help me

1. What if a user makes an inappropriate choice like 'dog'? How can we extend the function to handle that?

2. What if players in the game could also choose Rope in this game?

3. In this version, if both players make the same choice, the game returns a tie. What if the game didn't end there but instead asked both players for new choices?

 var compare = function compare(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";
                 }
        }

    };    

    var userChoice = function getuserChoice()
    {
       var theChoice= prompt("enter your choice");

    while(theChoice!=="rock"&& 
          theChoice!=="paper" && 
          theChoice!=="scissors");
          {
         return theChoice;
          }

    };
    userChoice = getuserChoice();
    console.log("userchoice is" : + " " + userChoice);
    console.log(compare("rock","scissors"));

#2

Hello samauden,
In the while block in the getuserChoice function, the operator that you used for the while condition (!==) is not recognized, causing the function to exit there, and miss the close parenthesis. The operator you need to put is != (single equals sign).

Hope that helps,
Drew