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

187
Views
Los principiantes primero intentan codificar piedra, papel... juego. Sigue regresando 'ganancias en papel'

Sigo obteniendo 'ganancias en papel' cuando ingreso 'rock' como mi elección.

 function game() { pChoice = prompt('What is your play?'); cChoice = ['rock','paper','scissor']; let compChoice = [Math.floor(Math.random() * cChoice.length)]; console.log(compChoice); function compare(pChoice, compChoice) { if (pChoice === compChoice) { alert( "It's a tie" ); } if (pChoice === 'rock') { if (compChoice === 'scissor') { return 'rock wins'; } else { return 'paper wins'; } } else if (pChoice === 'paper') { if (compChoice === 'rock') { return 'paper wins'; } else { return 'scissor wins'; } } else if (pChoice === 'scissor') { if (compChoice === 'paper') { return 'scissor wins'; } else { return 'rock wins'; } } } var result = compare(pChoice, compChoice); console.log(compare(pChoice, compChoice)); } game();
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Nunca asigna cChoice a un valor, sino que lo asigna a una matriz con un número.

Por ejemplo:

 // Assigning to [number] let compChoice = [Math.floor(Math.random() * cChoice.length)]; // Assigning to string inside of array cChoice let compChoice = cChoice[Math.floor(Math.random() * cChoice.length)];
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!