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

127
Views
El juego Rock Paper Scissors regresa indefinido junto con el resultado esperado

Al ejecutar la función, la consola registra el resultado esperado seguido de "Indefinido" directamente debajo y no puedo entender por qué. Estoy empezando a aprender javascript, así que estoy seguro de que esto será fácil de resolver, pero no lo veo en este momento.

 userInput = userInput.toLowerCase(); if(userInput !== 'rock' && userInput !== 'paper' && userInput !== 'scissors') console.log('Inocrrect choice, please try again'); return userInput; } const getComputerChoice = () => { let computerChoice = Math.floor(Math.random()*3); switch(computerChoice){ case 0: return 'rock'; break; case 1: return 'paper'; break; case 2: return 'scissors'; break; } } const determineWinner = (userChoice, computerChoice) => { if(userChoice === computerChoice) { console.log(`You chose ${userChoice} and the computer chose ${computerChoice}, you tied!`); } else if(userChoice === 'rock'){ if(computerChoice === 'scissors'){ console.log(`You chose ${userChoice} and the computer chose ${computerChoice}, you won!`); } else { console.log(`You chose ${userChoice} and the computer chose ${computerChoice}, you lost!`); } } else if(userChoice === 'paper'){ if(computerChoice === 'rock'){ console.log(`You chose ${userChoice} and the computer chose ${computerChoice}, you won!`); } else { console.log(`You chose ${userChoice} and the computer chose ${computerChoice}, you lost!`); } } else if(userChoice === 'scissors'){ if(computerChoice === 'paper'){ console.log(`You chose ${userChoice} and the computer chose ${computerChoice}, you won!`); } else { console.log(`You chose ${userChoice} and the computer chose ${computerChoice}, you lost!`); } } } const playGame = userInput => { const userChoice = getUserChoice(userInput); const computerChoice = getComputerChoice(); console.log(determineWinner(userChoice,computerChoice)); } playGame('rock');
about 4 years ago · Juan Pablo Isaza
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!