I'm having a problem. I can't get out of addEventListener when specific value is get after enormous time of clicking specific images.
function game(role){
playRound(role, computerPlay());
console.log(`Player: ${player_count} Computer: ${computer_count}`);
}
const buttons = document.querySelectorAll('button');
function pickRole(buttons){
buttons.forEach((button) => {
button.addEventListener('click', () => {
if (button.className === "btn-1"){
role = "rock";
}else if (button.className === "btn-2"){
role = "paper";
}else if (button.className === "btn-3"){
role = "scissors";
}
game(role);
});
});
}
pickRole(buttons);
My program is checking each statement inside playRound() function, and after 5 wins are get, I want it to be able to get out.