Syntax Error JavaScript

It is giving me a syntax error of });

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



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

const determineWinner = (userChoice, computerChoice) => {
  if (userChoice === computerChoice) {
    return 'Tie';
    }
  if (userChoice === 'rock') {
   if (computerChoice === 'paper') {
    return 'computer won';
    } else {
    return 'you win';
    }
  } 
  if (userChoice === 'paper') {
    if (computerChoice === 'scissors') {
      return 'computer won';
    } else {
      return 'you win'; 
    }
  } 
  if (userChoice === 'scissors') {
    if (computerChoice === 'rock') {
    return 'computer won'; 
    } else {
      return 'you win';
    }
  };


const playGame = () => {
  const userChoice = getUserChoice('rock');
  const computerChoice = getComputerChoice();
  console.log(userChoice);
  console.log(computerChoice);
  console.log(determineWinner(userChoice, computerChoice));
};

playGame()

1 Like

I could be wrong but I don’t see a closing bracket for the const determineWinner function.

Yeah you were right that was missing. Thanks.
Now it is giving me:

Error
undefined
paper
undefined

Got it figured out

Thank you

1 Like