title: Run function only once when button is clicked? Javascript
body: <p>I want the function home(); to execute only once. When the player chooses their weapon it creates a homepage button every time they click one of three buttons.
  how can it run once so only one homepage button is created regardless of how many times the game is played again?
  <a href="https://codepen.io/hamisakim/full/XWjVEbx" rel="nofollow noreferrer">https://codepen.io/hamisakim/full/XWjVEbx</a></p>
  <pre><code>function home(){ const button = document.createElement(&quot;button&quot;);
             button.innerHTML = &quot;Homepage&quot;;
              button.setAttribute(&quot;id&quot;,'homebutton')
                const postDiv = document.querySelector('#choices');
                  postDiv.appendChild(button);
                  
  
  function buttonClick(e) {
    home();
    const choices = [&quot;lapis&quot;, &quot;papyrus&quot;, &quot;scalpellus&quot;];
    const randomIndex = Math.floor(Math.random() * choices.length);
    computer.currentChoice = choices[randomIndex];
      document.querySelector(&quot;#homepageText&quot;).innerHTML = '';
      document.querySelector('h3').innerHTML = 'choose below to play again!';
    document.getElementById('choices').removeEventListener('click',null);
  </code></pre>