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

195
Views
Eventlistener arroja un error al analizar la función

Acabo de empezar a programar y este controlador de eventos no funciona.

TypeError no detectado: no se pudo ejecutar 'addEventListener' en 'EventTarget': el parámetro 2 no es del tipo 'Object'. en guión.js:51:33

 document.getElementById("rock").addEventListener("click", playRound("rock", computerPlay()));

Aquí está el código completo (no terminado):

 const answers = ["rock", "paper", "scissors"]; let playerScore = 0; let computerScore = 0; function computerPlay() { return answers[Math.floor(Math.random() * answers.length)]; } function playRound(playerSelection, computerSelection) { playerSelection = playerSelection.toLowerCase(); if (playerSelection == computerSelection) { return ("Tie!"); } else { switch (playerSelection) { case "rock": if (computerSelection == "paper" ) { computerScore++; return ("You lost! " + computerSelection + " beats " + playerSelection); } else { playerScore++; return ("You won! " + playerSelection + " beats " + computerSelection); } case "paper": if (computerSelection == "scissors" ) { computerScore++; return ("You lost! " + computerSelection + " beats " + playerSelection); } else { playerScore++; return ("You won! " + playerSelection + " beats " + computerSelection); } case "scissors": if (computerSelection == "rock" ) { computerScore++; return ("You lost! " + computerSelection + " beats " + playerSelection); } else { playerScore++; return ("You won! " + playerSelection + " beats " + computerSelection); } } } } console.log(typeof(computerPlay)); document.getElementById("rock").addEventListener("click", playRound("rock", computerPlay())); document.getElementById("paper").addEventListener("click", playRound("paper", computerPlay())); document.getElementById("scissors").addEventListener("click", playRound("scissors", computerPlay()));
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!