Help! Can't find my syntax error!

Hello, I’ve been trying to find my syntax error for quite a while here but can’t seem to figure it out. Please help me out.
This is the syntax error:
SyntaxError: Unexpected token )
at createScript (vm.js:53:10)
at Object.runInThisContext (vm.js:95:10)
at Module._compile (module.js:543:28)
at Object.Module._extensions…js (module.js:580:10)
at Module.load (module.js:488:32)
at tryModuleLoad (module.js:447:12)
at Function.Module._load (module.js:439:3)
at Module.runMain (module.js:605:10)
at run (bootstrap_node.js:427:7)
at startup (bootstrap_node.js:151:9)

This is my code I’ve been putting together.

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

const getComputerChoice = () => {
  const 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 'this game is a tie!';
  if (userChoice === 'rock') {
    if (computerChoice === 'paper') {
      return "Sorry, computer won!";
    } else {
      return "Congratulations, you won!";
  if (userChoice === 'paper') {
    if (computerChoice === 'scissors') {
      return 'Sorry, computer won!';
  } else { 
      return "Congratulations, you won!";
  if (userChoice === 'scissors') {
    if (computerChoice === 'rock') {
      return "Sorry, Computer won!";
  } else {
    return "Congratulations, you won!";

console.log(determineWinner('rock', 'scissors'));
console.log(determineWinner('paper', 'scissors'));
console.log(determineWinner('rock', 'rock'));

You must select a tag to post in this category. Please find the tag relating to the section of the course you are on E.g. loops, learn-compatibility

When you ask a question, don’t forget to include a link to the exercise or project you’re dealing with!

If you want to have the best chances of getting a useful answer quickly, make sure you follow our guidelines about how to ask a good question. That way you’ll be helping everyone – helping people to answer your question and helping others who are stuck to find the question and answer! :slight_smile:

1 Like

Hi thanks for sharing your code!

There’s two potential issues, one is the quote marks instead of ' and instead of " (I’m guessing this is from a non-English default keyboard). The other issues is that you’re missing some curly braces in your code }. Make sure you are indenting things in a way that it’s clear to you (and other readers) where your brackets begin and end. A code editor like vs code help tons for this purpose. A good way to figure out where the issues are is by commenting out sections of your code /* */ to see what’s throwing the error.

Remember that using the formatting button goes a long way for people to help you out (</>)

That’s one, of several, reasons why people really ought to correctly format their code in posts. Discourse swaps the quotes out for ones which cause issues in a lot of runtime environments… :slight_smile:

1 Like