Rock,Paper,Scissors Project

https://www.codecademy.com/paths/web-development/tracks/getting-started-with-javascript/modules/learn-javascript-functions/projects/rock-paper-scissors-javascript

Hello I am new to coding, and having difficulty with the Rock,Paper,Scrissors Project under Java script functions.

I am getting the error message: /home/ccuser/workspace/javascript_101_Unit_3/Unit_3/rockPaperScissors.js:26
if(userChoice === ‘rock’){
^

ReferenceError: userChoice is not defined

To my understanding the issue is line 26 or that the parameter userChoice is not defined. I am not sure how to define it in the body of the function determineWinner. I am not sure how to assign it a value.

An example of how to define it would be helpful.

Below is my code:

const getUserChoice = (userInput) => {
userInput = userInput.toLowerCase(); 
if(userInput === 'rock' || userInput === 'paper' || userInput === 'scissors'){
  return userInput
} else {
  return console.log('There is an 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 = function (userChoice,computerChoice)  {
  if(userChoice === computerChoice){
    return 'The game is a tie!';
  }
}

if(userChoice === 'rock'){
  return 'The computer won';
if(computerChoice === 'paper'){
} else{
  return 'You won';
}
}

Thank you for your time,
Devin

Hello, @raziel14.

Welcome to the forum!

The line referred to in the error message should be included inside your determineWinner() function.

P.S. When posting code please follow these guidelines: How do I format code in my posts?
It appears that one of our moderators formatted your code for you this time.

Hi, I am almost completed (on step 10/14) with the Rock, Paper, or Scissors Project, but I keep running into this error and I don’t know what needs fixing. Thanks, Ashley

Error:

/home/ccuser/workspace/javascript_101_Unit_3/Unit_3/rockPaperScissors.js:42
});
 ^
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)

Code:

const getUserChoice = userInput => userInput.toLowerCase() === 'rock' || userInput.toLowerCase() === 'paper' || userInput.toLowerCase() === 'scissors' ?  userInput : '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 'It/s a tie. Please try again!';
}
  if (userChoice === 'rock') {
    if (computerChoice === 'paper') {
      return 'Computer won!';
    } else {
      return 'You won!!!';
    }
  }

  if (userChoice === 'paper') {
    if (computerChoice === 'scissors') {
      return 'Computer won!';
    } else {
      return 'You won!!!';
    }
  }

  if (userChoice === 'scissors') {
    if (computerChoice === 'rock') {
      return 'Computer won!';
    } else {
      return 'You won!!!';
    }
  };
console.log(determineWinner('rock', 'scissors'));

A closing parenthesis would be expected after an opening parenthesis and an expression:

( expression )
so if it’s unexpected, then that’s not what you’ve got, is it?

if one thing is unexpected then what was expected, and why? would that suggest that you’ve started something that you haven’t finished?