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

134
Views
Problemas con los recuentos ganadores | Juego de piedra, papel o tijera

He tenido este problema durante varias horas y pensé que finalmente era hora de pedir ayuda. El problema es que mis cuentas ganadoras no se incrementarán de acuerdo con el ganador declarado en cada una de las 5 rondas. Lo siento si mi código es desordenado o demasiado complicado.

 // The initial variable declarations including the user's pre-picked input/ let computerChoice; let userChoice = 'paper'; // The function picks a random number that will change the computerChoice variable's value function computerPlay() { computerChoice = Math.floor(Math.random() * 3); switch (computerChoice) { case 0: computerChoice = 'rock'; break; case 1: computerChoice = 'paper'; break; case 2: computerChoice = 'scissors'; break; } } // The function will pick a round winner function userPlay(userChoice) { return userChoice.toLowerCase(); } function playRound() { computerPlay(); if ((computerChoice === 'rock' && userChoice === 'scissors') || (computerChoice === 'paper' && userChoice === 'rock') || (computerChoice === 'scissors' && userChoice === 'paper')) { return `You lost! Computer chose ${computerChoice}.` } else if (computerChoice === userChoice) { return `It's a tie! Computer chose ${computerChoice}.` } else { return `You won! Computer chose ${computerChoice}.` } } // The function will pick a winner of 5 rounds *not working* function game() { let userWinnerCount = 0; let computerWinnerCount = 0; let ties = 0; for (let i = 0; i < 5; i++) { console.log(playRound()); if (playRound() === `You won! Computer chose ${computerChoice}.`) { userWinnerCount += 1 } else if (playRound() === `You lost! Computer chose ${computerChoice}.`) { computerWinnerCount += 1 } else { ties += 1 } } console.log(`${userWinnerCount} - times the user won / ${computerWinnerCount} - times the computer won / ${ties} - Ties`); } game()

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!