title: Need to add a class when a checkbox is checked in javacript
body: <p>i'm challenging myself by creating a website that have a dark and light mode.</p>
  <p>When the checkbox is checked, it add the class &quot;light&quot; on the header for example, dark is default mode.</p>
  <p>I've created a script but i didn't found the solution and why it's not working, can someone help me in this direction?</p>
  <p>Here is my code:</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 header = document.getElementsByClassName('header');
  let switcher = document.querySelector('#switch');
  
  switcher.addEventListener('click',function(){
      if(this.checked){
          header.classList.add('light');
      }
      else{
       header.classList.remove('light');
       }
  })</code></pre>
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;div class="header "&gt;
              &lt;div class="title-section"&gt;
                  &lt;h1&gt;Social Media Dashboard&lt;/h1&gt;
                  &lt;p&gt;Total Followers: 23,004&lt;/p&gt;
              &lt;/div&gt;
              &lt;div class="switchbtn"&gt;
                  &lt;label for="switch" id="switchlabel"&gt;Dark Mode&lt;/label&gt;
                  &lt;input type="checkbox" name="switch" id="switch"&gt;
              &lt;/div&gt;
  &lt;/div&gt;</code></pre>
  </div>
  </div>
  </p>