Https://www.codecademy.com/courses/introduction-to-javascript/projects/rock-paper-scissors-javascript

could someone please tell me what is wron with this code

const getUserChoice = userInput => {

  userInput = userInput.toLowerCase();

  if (userInput === 'rock' || userInput === 'paper' ||userInput ==='scissors');}

  return userInput;

 else

 console.log('Error!, please type rock, paper or scissors.')

  const getComputerChoice = () => {

  const randomNumber = Math.floor(Math.random() * 3);

switch (randomNumber) {

  case 0:

    return 'rock';

  case 1:

    return 'paper';

  case 3:

  return 'scissors';

}

 if (userChoice === computerChoice) {

  return 'The game is a tie!';

};

if (userChoice === 'rock') {

  if (computerChoice === 'paper') {

    return 'The computer won!';

  } else {

    return 'You won!';

  }

}

if (userChoice === 'paper') {

  if (computerChoice === 'scissors') {

    return 'The computer won!';

  } else {

    return 'You won!';

  }

}

if (userChoice === 'scissors') {

  if (computerChoice === 'rock') {

    return 'The computer won!';

  } else {

    return 'You won!';

  }

}

console.log(determineWinner('paper', 'scissors')); // prints something like 'The computer won!'

console.log(determineWinner('paper', 'paper')); // prints something like 'The game is a tie!'

console.log(determineWinner('paper', 'rock')); // prints something like 'The user won!'

I would suggest looking at your first if statement:

if (userInput === 'rock' || userInput === 'paper' ||userInput ==='scissors');}

  return userInput;

 else

and compare it with how you’ve written your other if statements

1 Like

To add on, whenever you get SyntaxError: Unexpected token it usually means the error is coming before the marked line of code.