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

160
Views
SyntaxError no detectado: "token inesperado)" | If else declaración en JavaScript

Parece que mi condición if else tiene un error de sintaxis, ¿alguien puede ayudarme? La consola muestra este enlace { /home/ccuser/workspace/javascript_101_Unit_3_v2/rockPaperScissors.js:38 }); } y un error apunta a ")"

 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

Estás definiendo un recinto, pero te falta el 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

Solo te falta el último / cierre } para tu método determinWinner(...) .

¡Así es como debería verse tu código!

 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

Pruebe esto: Al final de computerChoice){ , agregue : ¡y vea si eso funciona!

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!