SyntaxError: Unexpected token )

When working on the Rock, Paper, Scissors project Rock Paper Scissors, I am stuck on step 11 because I keep receiving a “SyntaxError: Unexpected token )” message in the console after I add the code at line 20. I have read externally that this message indicates an adding a line to the bottom of the written code that includes characters that are expected but are not included.

I assume this means I am missing a “)” somewhere starting around line 20 but I can’t find the issue.

Here is my current code:

const getUserChoice = userInput => {
  userInput = userInput.toLowerCase();
  if (userInput === 'rock' || userInput === 'paper' || userInput === 'scissors') {
      return userInput;
  } else {
    console.log('Error. Try again.')}
};

const getComputerChoice = () => {
  let randomNumber = Math.floor(Math.random() * 3);
  switch (randomNumber) {
    case 0:
      return 'rock';
    case 1:
      return 'paper';
    case 2:
      return 'scissors';
  }
};

const determineWinner = (userChoice, computerChoice) => {
  if (userChoice === computerChoice) {
      return 'It is a tie.';
      };
  if (userChoice === 'rock') {
      if (computerChoice === 'paper') {
          return 'Paper covers rock. You loose.';
          } else {
          return 'Rock smashes scissors. You WIN!';
      };
  if (userChoice === 'paper') {
      if (computerChoice === 'scissors') {
          return 'Scissors cuts paper. You loose.';
          } else {
          return 'Paper covers rock. You WIN!';
      };
   if (userChoice === 'scissors') {
      if (computerChoice === 'rock') {
          return 'Rock smashes scissors. You loose.';
          } else {
          return 'Scissors cuts paper. You WIN!';
      };
   };

Thanks in advance!

the error message is indeed not very clear, but you do miss closing curly brackets. For example, here:

  if (userChoice === 'rock') {
      if (computerChoice === 'paper') {
          return 'Paper covers rock. You loose.';
          } else {
          return 'Rock smashes scissors. You WIN!';
      };

i don’t see the } to close the first if? This is one of many missing curly brackets (forgetting to close the function)

That did it. Thanks so much!

No it says the opposite of that. It says it found a ) where one was not expected. Why would that be? How about this code:

)

That would be unexpected, there’s no opening brace.
Your inconsistent brackets are causing things that come after your code (node wraps your code inside a function) to not yet be expected.
With a more recent node version you’d get an improved error message that doesn’t refer to things not found in your code:

SyntaxError: Unexpected end of input

Where the input is your code, so, unexpected end of code, because, close your brackets.

In general, keep your brackets balanced at all times and your indentation matching. Using a half-decent text editor can help you with both formatting and balancing, making such issues look weird and stand out or outright prevent you from introducing them in the first place.