title: classList.remove and .add not working for some reason
body: <p>When toggling the switch I get these errors from the browser console. For some reason it does not work and I can't solve why this won't work I am just starting Javascript so don't me mad at me if I did something stupid.</p>
  <pre><code>Uncaught TypeError: Cannot read properties of undefined (reading 'remove')
      at getValue (darkModeSwitch.js:8)
      at window.onload (index.html:17)
  
  Uncaught TypeError: Cannot read properties of undefined (reading 'add')
      at getValue (darkModeSwitch.js:13)
      at HTMLInputElement.onclick (index.html:26)
  </code></pre>
  <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>const body = document.body
  const anchor = document.getElementsByTagName("a");
  const darkModeToggle = document.getElementById('darkModeToggle');
  
  function getValue(){
    if (darkModeToggle.checked) {
        body.classList.remove("lightmode")
        anchor.classList.remove("lightmode")
        console.log("checked")
    } else{
        console.log("not checked")
        body.classList.add("lightmode")
        anchor.classList.add("lightmode")
    }
  };</code></pre>
  <pre class="snippet-code-css lang-css prettyprint-override"><code>.lightmode{
      background-color: white;
      color: black;
  }</code></pre>
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;div&gt;
      &lt;ul&gt;
          &lt;li&gt;&lt;a href="kapcsolat/kapcsolat.html?version=691"&gt;Kapcsolat&lt;/a&gt;&lt;/li&gt;
          &lt;li&gt;&lt;a href="projects/projects.html?version=691"&gt;Projektek&lt;/li&gt;
          &lt;li&gt;&lt;a class="active" href="index.html?version=692"&gt;Kezdőlap&lt;/a&gt;&lt;/li&gt;
          &lt;li&gt;&lt;label class="switch"&gt;&lt;input onclick="getValue()" id="darkModeToggle" type="checkbox" checked&gt;&lt;span class="slider round"&gt;&lt;/span&gt;&lt;/label&gt;&lt;script src="scripts/darkModeSwitch.js"&gt;&lt;/script&gt;
          &lt;/li&gt;
          &lt;h1 class="jayden" style="float: left;"&gt;&lt;a class="jayden" href="index.html?version=-23424893215"&gt;jayden.hu&lt;/a&gt;&lt;/h1&gt;  
      &lt;/ul&gt;
  &lt;/div&gt;</code></pre>
  </div>
  </div>
  </p>