In this snippet of code:
let rockClick = rockBtn.addEventListener('click', playRound.bind("rock", computerPlay(), false));
After using console.log()
, the output is undefined
. The purpose of rockBtn
:
const rockBtn = document.querySelector("#rock");
is to target the button with the id of #rock
. Clicking on this button should trigger the playRound
function with "rock"
as its first parameter and computerPlay()
as the second. This function is responsible for conducting a single round of rock paper scissors.
Nevertheless, when I click the rock button, nothing occurs, prompting me to assign the rockBtn.addEventListener
to a variable and utilize console.log()
, which yields undefined
. Why is this outcome arising? How can it be resolved?
For reference, here is the fiddle link: https://jsfiddle.net/JaredDev/8syrwfm9/48/