title: How do I get my rock paper scissors game to reset after 5 wins with javascript (The Odin Project)?
body: <p>I have tried making a function <code>endGame()</code> but I just can't figure out exactly what I need to do to reset everything back to 0. I've used <code>result_p.innerHTML</code> to change the message to say who has won the game after 5 points (user or computer) but the user can still continue after this and I'd like to actually have the game reset to 0-0. Any suggestions? Thanks</p>
  <p>Code Below:</p>
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>let userScore = 0;
  let compScore = 0;
  
  const userScore_span = document.getElementById("user-score");
  const compScore_span = document.getElementById("comp-score");
  // Get reference to scoreboard div 
  const scoreBoard_div = document.querySelector(".score-board");
  const result_p = document.querySelector(".result &gt; p");
  const rock_div = document.getElementById("r");
  const paper_div = document.getElementById("p");
  const scissors_div = document.getElementById("s");
  
  //Gets random selection from computer 
  function getComputerSelection() {
      const choices=['r','p','s'];
      const result = Math.floor(Math.random()*3);
      return choices[result]
  } 
  //Converts r,p,s to rock, paper, scissors for output on screen
  function convertToWord(letter) {
      if (letter === 'r') return "Rock";
      if (letter === 'p') return "Paper";
      return "Scissors";
  }
  
  function win(playerSelection, computerSelection) {
      userScore++;
      userScore_span.innerHTML = userScore;
      compScore_span.innerHTML = compScore;
  
      if (userScore &lt; 5){result_p.innerHTML = `${convertToWord(playerSelection)} beats ${convertToWord(computerSelection)}. You win! =D`;
  }else if(userScore === 5){result_p.innerHTML='Game over, you win! Refresh to play again'}; 
  }
  
  function lose(playerSelection, computerSelection) {
      compScore++;
      userScore_span.innerHTML = userScore;
      compScore_span.innerHTML = compScore;
      
      if (compScore&lt;5){result_p.innerHTML = `${convertToWord(computerSelection)} beats ${convertToWord(playerSelection)}. You lose =(`;
  }else if(compScore === 5){result_p.innerHTML='Game over, you lose! Refresh to play again'};
  }
  
  function draw() {
      userScore_span.innerHTML = userScore;
      compScore_span.innerHTML = compScore;
      result_p.innerHTML = `It\'s a tie!`;
  }
  
  function game(playerSelection) {
      const computerSelection = getComputerSelection();
      
      if (playerSelection === computerSelection) {
          draw(playerSelection, computerSelection);
        } else if (playerSelection === 'r' &amp;&amp; computerSelection === 's'){
          win(playerSelection, computerSelection);  
        }else if (playerSelection === 'p' &amp;&amp; computerSelection === 'r'){
          win(playerSelection, computerSelection);
        }else if (playerSelection === 's' &amp;&amp; computerSelection === 'p'){
          win(playerSelection, computerSelection);
        }else{
          lose(playerSelection, computerSelection);
        }   
      }
  
  
  
  
  function main() {
      
  rock_div.addEventListener('click', () =&gt; game("r"));
  
  paper_div.addEventListener('click', () =&gt; game("p"));
  
  scissors_div.addEventListener('click', () =&gt; game("s"));
  
  }
  main ();</code></pre>
  <pre class="snippet-code-html lang-html prettyprint-override"><code>your score: &lt;div id="user-score"&gt;&lt;/div&gt; &lt;br&gt;
  computer's score: &lt;div id="comp-score"&gt;&lt;/div&gt;
  &lt;div id="a1" class="score-board"&gt;&lt;/div&gt;
  &lt;div id="a2" class="result"&gt;&lt;p&gt;&lt;/p&gt;&lt;/div&gt;
  &lt;button id="r"&gt;use rock&lt;/button&gt;
  &lt;button id="p"&gt;use paper&lt;/button&gt;
  &lt;button id="s"&gt;use scissor&lt;/button&gt;</code></pre>
  </div>
  </div>
  </p>