Error on line that does not exist?

When I try to run my script, I am receiving the following 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 script:

const getUserChoice = userInput => {
  userInput = userInput.toLowerCase();
  if (userInput === 'rock' || userInput === 'paper' || userInput === 'scissors'){
    return userInput;
  } else {
    console.log('Error, not a valid Rock - Paper - Scissors choice.');
function getComputerChoice(){
    let randomNumber = Math.floor(Math.random() * 3);
    if (randomNumber === 0){
      return 'rock';
    } else if (randomNumber === 1){
      return 'paper';
    } else {
      return 'scissors';
  function determineWinner(userChoice,computerChoice){
    if (userChoice === computerChoice){
      return 'It is a draw!';
    } if (userChoice === 'rock' && computerChoice === 'scissors'){
        return 'You win!';
      } else {
        return 'You lose!';
      } if (userChoice === 'paper' && computerChoice === 'rock'){
          return 'You win!';
        } else {
          return 'You lose!';
        } if (userChoice === 'scissors' && computerChoice === 'paper'){
            return 'You win!';
          } else {
          return 'You lose!';
function playGame(){
  let userChoice = getUserChoice('rock');
  let computerChoice = getComputerChoice();

It appears that a syntax error is occurring at line 44, yet my script is only written in 43 lines according to Codecademy.

Link to lesson:

Hello @louismedina449869610, welcome to the forums! Look at your determineWinner function. Does the number of opening braces { match the number of closing braces }?

1 Like

I just saw that missing closing brace. Is the error line identifier supposed to be a numerical value of 10 ahead of the actual error line? I noticed the missing brace should have gone on line 34, not 44. So far the errors I’ve encountered have been on the actual error line given by the interface.

It’s just that line 44 is the last line of your code (notice if you copy/paste it, there’s a blank line after playGame();. The compiler is basically saying “I looked all the way to the end of your code, and there’s no sign of the closing brace.” For example, this code would throw a similar error:

function a(){

(just on line three)

1 Like

See that’s where I am confused. I did copy and paste the code(via the copy to clipboard button. Then I reset the project and pasted, it still only indicated 43 lines existed. Then I pasted it onto a notepad doc and I only counted 43 lines. I also tried another website’s JS reader and it said only 43 lines existed. Maybe it was a bug? Either way, I know how to interpret that error in the future so thank you.

1 Like

No problem!

Hm. Well maybe the original code accidentally had a forty fourth line, or maybe it was a slight bug, I can’t answer that one…