title: JQuery/Javascript: Getting locally changed booleans
body: <p>I'm having some trouble with booleans and scope. I have set a global boolean to false, upon a function the boolean turns true. if the boolean is true I want another function to run. However the boolean is only changed in the scope of the function that makes it true and is still false globally. Thus the following function which needs the boolean to be true is not running.</p>
  
  <p>The first part of my code looks something like this:</p>
  
  <pre><code>let threePick= false;
  let twoPick = false;
  let onePick = false;
  let found = false;
  var startGame = false;
  function selector() {
      $("#threebut").click(function () {
          if (found === false) {
              found = true;
              onePick = true;
              twoPick = true;
              var input = this;
              input.disabled = true;
          }
      })
      $("#onebut").click(function () {
          if (found === false) {
              found = true;
              threePick = true;
              twoPick = true;
              var input = this;
              input.disabled = true;
          }
      })
      $("#twobut").click(function () {
          if (found === false) {
              found = true;
              threePick = true;
              onePick=true;
              var input = this;
              input.disabled = true;
          };
      });
  };
  selector();
  function enemy() {
      $("#twobut").click(function () {
          if (twoPick === true){
          var input = this;
          input.disabled = true;
         startGame = true;
      }
      });
     $("#threebut").click(function() {
         if (threePick === true){
  
          input.disabled = true;
          startGame = true;   
         }
     });
     $("#twobut").click(function() {
         if (twoPick === true){
          var input = this;
          input.disabled = true;
          startGame = true; 
         }
     });
  }
  enemy();
  </code></pre>
  
  <p>Notice that the enemy(); changes the startGame boolean to true
  Now in the next part of my code:</p>
  
  <pre><code>function gameStart(){
      if (startGame === true){
          var button = $('&lt;button/&gt;', {
              text: 'Attack'
          })
          $('#atkButton').append(button);
      }
  }
  gameStart();
  </code></pre>
  
  <p>I want the function to run when the boolean is true but the boolean only changes locally. I know that accessing local variables is not possible but is there any way around this or an alternative I could use?</p>
  
  <p>P.S I apologise for my inefficient code I've only been doing javascript for a few days.
  Any help is appreciated!</p>