Need Help! JavaScript Rock, Paper, Scissors project

Link to project: https://www.codecademy.com/courses/introduction-to-javascript/projects/rock-paper-scissors-javascript

This is my first time at coding, so maybe the answer will be something simple.
I’m stuck on page 11 of this project, where you run the code for determineWinner. I tested at step 7 and console.log(determineWinner(‘rock’,‘rock’)); and other variations of if (userChoice === computerChoice){ return ‘Game is a tie!’; worked fine.

Now that I’ve added the code for Steps 8 - 10 (see below), nothing runs. the error is:
/home/ccuser/workspace/javascript_101_Unit_3/Unit_3/rockPaperScissors.js:44
return 'User won!;
^^^^^^^^^^^
SyntaxError: Invalid or 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)

CODE:
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’;
case 1:
return ‘paper’;
case 2:
return ‘scissors’;
}
}
const determineWinner = (userChoice, computerChoice) =>{
if (userChoice === computerChoice){
return ‘Game is a tie!’;
}

if (userChoice === ‘rock’){
if (computerChoice === ‘paper’){
return ‘User won!’;
} else {
return ‘The computer won!’;
}
}

if (userChoice === ‘paper’){
if (computerChoice === ‘rock’){
return ‘The computer won!’;
} else {
return ‘User won!’;
}
}

if (userChoice === 'scissors'){
  if (computerChoice === 'paper'){
  return 'User won!;
} else {
  return 'The computer won!';
}

}
}
console.log(determineWinner(‘rock’,‘rock’));

NOTE: After adding the code for a winner, the code for a tie no longer works. If I remove everything back to step 7. It’s fine. I’ve gone through and checked my work against the video and even started over completely, with the same results.

Thanks in advance for any help.
Gayle

Looks like you’re just missing the closing quotation mark '
Happy coding!

1 Like

THANK-YOU!!! I checked the brackets and curly brackets and missed that one quotation. It’s now working as expected. Whew!!

1 Like

You’re welcome! One tip for future posts, when you post code, please post it between sets of 3 back tics. You can type the back tics yourself (located below the ‘esc’ key on most keyboards, or click on the </> icon above, and paste your code in the area specified:

```
type or paste code here
```

This preserves your original formatting making it much easier to read. :wink:

OK, will do.
After you gave the solution I noticed that the error message actually showed what the issue was, since 'User won! was also missing the quotation mark. The learning curve is now a little less steep.
Thanks again.

1 Like