Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

138
Views
Uncaught SyntaxError: "Unexpected token )" | If else statement in JavaScript

It seems my if else condition has a syntax error, can somebody help? The console spits out this link { /home/ccuser/workspace/javascript_101_Unit_3_v2/rockPaperScissors.js:38 }); } and an error points to the ")"

  userInput = userInput.toLowerCase();
  if (userInput !== "rock" && userInput !== "paper" && userInput !== "scissor") {
    console.log("Error");
  } else {
    return userInput;
  }
}

const getComputerChoice = () => {
  const randomNumber = Math.floor(Math.random() * 3);
  switch(randomNumber){
    case 0: return "scissor";
    break;
    case 1: return "rock";
    break;
    default: return "paper";
    break;
  }
}

const determinWinner = (userChoice, computerChoice) => {
  if(userChoice === computerChoice){
    return "Its a tie";
  } else if (userChoice === "rock" && computerChoice ==="scissor"){
    return "The user won";
  } else if (userChoice === "paper" && computerChoice ==="rock"){
    return "The user won";
  } else if (userChoice === "scissor" && computerChoice ==="paper"){
    return "The user won";
  } else if (userChoice === "rock" && computerChoice ==="paper"){
    return "The computer won";
  } else if (userChoice === "paper" && computerChoice ==="scissor"){
    return "The computer won";
  } else if (userChoice === "scissor" && computerChoice ==="rock"){
    return "The computer won";
  }
about 4 years ago · Juan Pablo Isaza
3 answers
Answer question

0

You defining an enclosure, but you're missing the final }

  const determinWinner = (userChoice, computerChoice) => {
  if(userChoice === computerChoice){
    return "Its a tie";
  } else if (userChoice === "rock" && computerChoice ==="scissor"){
    return "The user won";
  } else if (userChoice === "paper" && computerChoice ==="rock"){
    return "The user won";
  } else if (userChoice === "scissor" && computerChoice ==="paper"){
    return "The user won";
  } else if (userChoice === "rock" && computerChoice ==="paper"){
    return "The computer won";
  } else if (userChoice === "paper" && computerChoice ==="scissor"){
    return "The computer won";
  } else if (userChoice === "scissor" && computerChoice ==="rock"){
    return "The computer won";
  }
}
about 4 years ago · Juan Pablo Isaza Report

0

You are just missing the last/closing } for your determinWinner(...) method.

This is how you code should look like!

const determinWinner = (userChoice, computerChoice) => {
  if(userChoice === computerChoice){
    return "Its a tie";
  } else if (userChoice === "rock" && computerChoice ==="scissor"){
    return "The user won";
  } else if (userChoice === "paper" && computerChoice ==="rock"){
    return "The user won";
  } else if (userChoice === "scissor" && computerChoice ==="paper"){
    return "The user won";
  } else if (userChoice === "rock" && computerChoice ==="paper"){
    return "The computer won";
  } else if (userChoice === "paper" && computerChoice ==="scissor"){
    return "The computer won";
  } else if (userChoice === "scissor" && computerChoice ==="rock"){
    return "The computer won";
  }
}
about 4 years ago · Juan Pablo Isaza Report

0

Try this: At the end of computerChoice){, add : and see if that works!

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!