I need help with my code please

const getUserChoice = userInput => {
userInput = userInput.toLowerCase();
if (userInput === ‘rock’ || userInput === ‘paper’ || userInput === ‘scissors’) {
return userInput;
} else {
console.log(‘Error! 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 2:
return ‘scissors’;
}
};
const determineWinner = (userChoice, computerChoice) => {
if (userChoice === computerChoice) {
return ‘You both tie!’;
}
if (userChoice === ‘rock’) {
if (computerChoice === ‘paper’) {
return “The computer whooped yo ■■■!”;
} else {
return “You won CUHHH!!”;
}
if (userChoice === ‘paper’) {
if (computerChoice === ‘scissors’) {
return “The computer whooped yo ■■■!”;
} else {
return “You won CUHHH!!”;
}
if (userChoice === ‘scissors’) {
if (computerChoice === ‘rock’) {
return “The computer whooped yo ■■■!”;
} else {
return “You won the game!!”;
}
}
};
console.log(determineWinner(‘paper’, ‘scissors’));

Ok this is the error

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

You are missing a ) on the line with const randomNumber
or you could take out the first ( .

You’re missing a } immediately before
if (userChoice === 'paper') {

You’re missing a } immediately before
if (userChoice === 'scissors') {

quoted code

Next time, please use the </> button when posting your code, and put the code between the ``` and ``` so that your code keeps it’s formatting in the post.

2 Likes