title: How to use if(checkbox.checked) to disable a particular javascript?
body: <p>I am currently experimenting with a script, and I want to add a checkbox to allow user to either activate it or not, based on their preference.</p>
  <p>I've simplified the sample to show only the script that I need to turn on/off (the one that makes other buttons unclickable depending on which is specified.)</p>
  <p>How it should work is:</p>
  <p>if the checkbox is <strong>checked</strong>, <strong>allow</strong> script.</p>
  <p>if the checkbox is <strong>unchecked</strong>, <strong>disable</strong> the script (make this script inactive and allow users to use the tool however they want).</p>
  <p>However, I cannot complete the part that will add a checkbox functionality. Here's what my code looks like:</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>function enabledisablebuttons() {
    var checkBox = document.getElementById("enabledisablecheckbox");
      //Should I add another var in here?
  
      function resetallamnotes() {
          document.getElementById("1st").disabled = false;
          document.getElementById("2nd").disabled = false;
          document.getElementById("3rd").disabled = false;
          document.getElementById("4th").disabled = false;
      }       
  
      function amnotesDisable1st() {
          document.getElementById("1st").disabled = true;
          document.getElementById("2nd").disabled = true;
          document.getElementById("3rd").disabled = true;
          document.getElementById("4th").disabled = true;
      }
      function amnotesDisable2nd() {
          document.getElementById("1st").disabled = true;
          document.getElementById("2nd").disabled = true;
          document.getElementById("3rd").disabled = true;
          document.getElementById("4th").disabled = false;
      }
      function amnotesDisable3rd() {
          document.getElementById("1st").disabled = true;
          document.getElementById("2nd").disabled = false;
          document.getElementById("3rd").disabled = true;
          document.getElementById("4th").disabled = true;
      }
      function amnotesDisable4th() {
          document.getElementById("1st").disabled = false;
          document.getElementById("2nd").disabled = true;
          document.getElementById("3rd").disabled = true;
          document.getElementById("4th").disabled = true;
      }
  
    if (checkBox.checked == true){
    
      //What to enter here
      
    } else {
    
      //And also here
    }
  }</code></pre>
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;label for="enabledisablecheckbox"&gt;Checkbox:&lt;/label&gt; 
  
  &lt;input type="checkbox" id="enabledisablecheckbox" onclick="enabledisablebuttons()"&gt;
  
  &lt;br&gt;
  
  &lt;button class="cbtn" onclick="resetallamnotes()"&gt;Reset&lt;/button&gt;
  
  &lt;br&gt;&lt;br&gt;
          
  &lt;button id="1st" onclick="amnotesDisable1st()"&gt;1&lt;/button&gt;
              
  &lt;button id="2nd" onclick="amnotesDisable2nd()"&gt;2&lt;/button&gt;
              
  &lt;button id="3rd" onclick="amnotesDisable3rd()"&gt;3&lt;/button&gt;
              
  &lt;button id="4th" onclick="amnotesDisable4th()"&gt;4&lt;/button&gt;</code></pre>
  </div>
  </div>
  </p>
  <p>I'm really new to coding, especially JS, but I really really need this feature now to work. Thank you in advance!</p>