Rock paper scissors


Why my code is not working? I did not find out.

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

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

function determineWinner (userChoice, computerChoice) {
  if (userChoice === computerChoice) {
    return 'Tied!';
  if(userChoice ==='rock') {
    if (computerChoice ==='paper') {
      return 'The computer won!';
    } else {
      return 'You won!';
  if (userChoice === 'paper') {
    if (computerChoice ==='scissors') {
      return 'The computer won!';
    } else {
      return 'You won!';
  if (userChoice ==='scissors') {
    if(computerChoice ==='rock') {
      return 'The computer won!';
    } else {
      return 'You won!';

I check all bracket to ensure but still giving this 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)

Is there anyone can help me??


if i look at the syntax error, it says:


yet i see no }); in your code, how is that possible? The code you posted is not the same code as the code that throws an error


This is a weird situation because when I substract the last bracket in my code, it is not giving an error, however my code is still not working.


Please post an updated version of your code


Nodejs puts the code in a function

@bilalkah yes, it’s about odd brackets, but what you posted doesn’t have that issue (something else was executed)


This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.