I'm making a rock, paper, scissors game with plain JavaScript. I have three divs with choices for rock, paper, or scissors, which the user can click. I have another empty div which I would like to update with the text of the div the user clicks on ('rock', 'paper', or 'scissors'). However, the text shows up as 'undefined' each time. My code is below. Any ideas what I'm doing wrong?
const yourChoice = document.querySelector('#your-choice');
function userChoice() {
yourChoice.innerHTML = this.innerHTML;
}
<div id="your-choice-container">
<div id="your-choice"></div>
</div>
<div id="choice-container">
<div class="choice" id="rock" onclick="userChoice()">Rock</div>
<div class="choice" id="paper" onclick="userChoice()">Paper</div>
<div class="choice" id="scissors" onclick="userChoice()">Scissors</div>
</div>