Scissors, Paper, Rock - Syntax Issue

Hi,

I’m currently returning a syntax error for the below code snippet. The error being returned is:

/home/ccuser/workspace/javascript_101_Unit_3/Unit_3/rockPaperScissors.js:13
return: ‘rock’;
^
SyntaxError: Unexpected token :

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

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

Here’s a link to the current project I’m working on: https://www.codecademy.com/courses/introduction-to-javascript/projects/rock-paper-scissors-javascript

I’ve followed the walkthrough exactly and cant’ see where I’m messing this up. Any advice would be greatly appreciated!

Cheers,
Pete.

return doesn’t need a :

simply return ‘rock’ etc.

1 Like

Thanks so much! Perfect!

Yes, you are very welcome. But for future troubleshooting I suggest to you to read the error message thoroughly and draw conclusions on that. All the information is there.

js:13 means in the 13th line of code of the js file

return: 'rock' is the snippet of code where it encounters a syntax error

And the SyntaxError it returns is that is found a token “:” it did not expect being there.

1 Like

Haha, nice one. I definitely didn’t read that thoroughly enough. Thanks so much for the pointers.

2 Likes